コード例 #1
0
  protected void changeObject() {
    Employee employee = (Employee) this.workingCopy;
    employee.setFirstName("Bob");

    employee.setPhoneNumbers(new Vector());
    employee.addPhoneNumber(
        new org.eclipse.persistence.testing.models.employee.domain.PhoneNumber(
            "home", "613", "2263374"));
    employee.addPhoneNumber(
        new org.eclipse.persistence.testing.models.employee.domain.PhoneNumber(
            "office", "416", "8224599"));
  }
コード例 #2
0
  public void test() {
    UnitOfWork uow = getSession().acquireUnitOfWork();
    UnitOfWork uow2 = getSession().acquireUnitOfWork();

    baseEmp = (Employee) uow.readObject(Employee.class);
    for (int count = 20; count > 0; --count) {
      baseEmp.addPhoneNumber(
          new PhoneNumber(String.valueOf(count), String.valueOf(count), "5555555"));
    }
    uow.commit();

    Runnable runnable1 =
        new Runnable() {
          public void run() {}
        };

    Runnable runnable2 =
        new Runnable() {
          public void run() {
            try {
              for (int count = 20; count > 0; --count) {
                UnitOfWork uow = getSession().acquireUnitOfWork();
                Employee emp = (Employee) uow.readObject(baseEmp);
                emp.getPhoneNumbers();
                uow.revertObject(emp);
              }
            } catch (ConcurrentModificationException ex) {
              exception = true;
            }
          }
        };
    Thread thread1 = new Thread(runnable2);
    thread1.start();
    try {
      for (int count = 20; count > 0; --count) {
        uow = getSession().acquireUnitOfWork();
        Employee emp = (Employee) uow.readObject(baseEmp);
        emp.getPhoneNumbers().remove(0);
        uow.commit();
      }
    } catch (ConcurrentModificationException ex) {
      exception = true;
    }
    try {
      thread1.join();
    } catch (InterruptedException ex) {
    }
  }
コード例 #3
0
 protected void modifyCollection(UnitOfWork uow, Object objectToModify) {
   PhoneNumber newPhoneNumberWC = (PhoneNumber) uow.registerNewObject(newItemForCollection());
   ((Employee) objectToModify).addPhoneNumber(newPhoneNumberWC);
 }