use of org.eclipse.persistence.testing.models.employee.domain.EmployeePopulator in project eclipselink by eclipse-ee4j.
the class DoubleNestedUnitOfWorkDeleteConformedNestedNewObjectTest method test.
@Override
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");
}
}
use of org.eclipse.persistence.testing.models.employee.domain.EmployeePopulator in project eclipselink by eclipse-ee4j.
the class DoubleNestedUnitOfWorkRegisterNewObjectTest method test.
@Override
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");
}
}
use of org.eclipse.persistence.testing.models.employee.domain.EmployeePopulator in project eclipselink by eclipse-ee4j.
the class NestedUnitOfWorkDeleteConformedNestedNewObjectTest method test.
@Override
public void test() {
UnitOfWork uow = getSession().acquireUnitOfWork();
UnitOfWork nestedUow1 = uow.acquireUnitOfWork();
Employee employee = (Employee) new EmployeePopulator().basicEmployeeExample1();
employee.setId(new BigDecimal(15));
nestedUow1.registerObject(employee);
nestedUow1.commit();
nestedUow1 = uow.acquireUnitOfWork();
ReadAllQuery query = new ReadAllQuery();
query.setReferenceClass(Employee.class);
query.setSelectionCriteria(new org.eclipse.persistence.expressions.ExpressionBuilder().get("id").equal(new BigDecimal(15)));
query.conformResultsInUnitOfWork();
Vector results = (Vector) nestedUow1.executeQuery(query);
if (results.size() > 1) {
throw new TestErrorException("The read all query on primary key returned more than one object see bug # 3183379");
}
Employee nestedEmployee = (Employee) results.firstElement();
nestedUow1.deleteObject(nestedEmployee);
nestedUow1.commit();
if (!((UnitOfWorkImpl) uow).getNewObjectsCloneToOriginal().isEmpty()) {
throw new TestErrorException("Failed to unregister the Object in the nested unit of work");
}
}
use of org.eclipse.persistence.testing.models.employee.domain.EmployeePopulator in project eclipselink by eclipse-ee4j.
the class NestedUnitOfWorkDeleteNestedNewObjectTest method test.
@Override
public void test() {
UnitOfWork uow = getSession().acquireUnitOfWork();
UnitOfWork nestedUow1 = uow.acquireUnitOfWork();
Employee employee = (Employee) new EmployeePopulator().basicEmployeeExample1();
Employee nestedEmployee = (Employee) nestedUow1.registerObject(employee);
nestedUow1.deleteObject(nestedEmployee);
nestedUow1.commit();
uow.commit();
if (((UnitOfWorkImpl) uow).getNewObjectsCloneToOriginal().containsKey(employee)) {
throw new TestErrorException("Failed to unregister the Object in the nested unit of work");
}
}
use of org.eclipse.persistence.testing.models.employee.domain.EmployeePopulator in project eclipselink by eclipse-ee4j.
the class NestedUnitOfWorkNewObjectWithIndirectionTest method setup.
@Override
public void setup() {
getAbstractSession().beginTransaction();
Employee emp = (Employee) new EmployeePopulator().basicEmployeeExample1();
original = (Employee) new EmployeePopulator().basicEmployeeExample2();
original.getManagedEmployees().add(emp);
emp.setManager(original);
}
Aggregations