public void test() { UnitOfWork uow = getSession().acquireUnitOfWork(); UnitOfWork nestedUow1 = uow.acquireUnitOfWork(); UnitOfWork nestedNestedUOW = nestedUow1.acquireUnitOfWork(); Employee employee = (Employee) new EmployeePopulator().basicEmployeeExample1(); employee.setId(new BigDecimal(15)); Employee nestedEmployee = (Employee) nestedNestedUOW.registerObject(employee); nestedNestedUOW.commit(); nestedUow1.commit(); nestedUow1 = uow.acquireUnitOfWork(); nestedNestedUOW = nestedUow1.acquireUnitOfWork(); ReadObjectQuery query = new ReadObjectQuery(); query.setReferenceClass(Employee.class); query.setSelectionCriteria( new org.eclipse.persistence.expressions.ExpressionBuilder() .get("id") .equal(new BigDecimal(15))); query.conformResultsInUnitOfWork(); nestedEmployee = (Employee) nestedNestedUOW.executeQuery(query); nestedNestedUOW.deleteObject(nestedEmployee); nestedNestedUOW.commit(); nestedUow1.commit(); if (!((UnitOfWorkImpl) uow).getNewObjectsCloneToOriginal().isEmpty()) { throw new TestErrorException("Failed to unregister the Object in the nested unit of work"); } }
protected void setup() { super.setup(); // Acquire first unit of work this.unitOfWork = getSession().acquireUnitOfWork(); this.nestedUnitOfWork = unitOfWork.acquireUnitOfWork(); this.unitOfWorkWorkingCopy = (Employee) this.unitOfWork.registerObject(this.objectToBeWritten); this.nestedUnitOfWorkWorkingCopy = (Employee) this.nestedUnitOfWork.registerObject(this.unitOfWorkWorkingCopy); }