use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class GetFromNewObjectWithConformTest method test.
@Override
public void test() {
UnitOfWork uow = getSession().acquireUnitOfWork();
emp = new Employee();
emp.setFirstName("SomeName");
emp.setLastName("Some Last Name");
uow.registerObject(emp);
ReadObjectQuery query = new ReadObjectQuery(Employee.class);
query.conformResultsInUnitOfWork();
uow.getIdentityMapAccessor().initializeAllIdentityMaps();
emp = (Employee) uow.executeQuery(query);
uow.release();
}
use of org.eclipse.persistence.testing.models.employee.domain.Employee 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.Employee in project eclipselink by eclipse-ee4j.
the class NestedUnitOfWorkDeleteFromNestedObjectTest method test.
@Override
public void test() {
UnitOfWork uow = getSession().acquireUnitOfWork();
UnitOfWork nestedUow1 = uow.acquireUnitOfWork();
ReadAllQuery query = new ReadAllQuery();
query.setReferenceClass(Employee.class);
ExpressionBuilder expressionBuilder = new ExpressionBuilder();
query.setSelectionCriteria(expressionBuilder.get("firstName").equal("Bob").and(expressionBuilder.get("lastName").equal("Smith")));
query.conformResultsInUnitOfWork();
Vector<Employee> results = (Vector<Employee>) uow.executeQuery(query);
Employee employee = results.firstElement();
Employee employeeNested = (Employee) nestedUow1.registerObject(employee);
assertTrue(employeeNested.getPhoneNumbers().size() > 0);
for (PhoneNumber item : new Vector<PhoneNumber>(employeeNested.getPhoneNumbers())) {
if (item != null) {
nestedUow1.deleteObject(item);
employeeNested.removePhoneNumber(item);
}
}
nestedUow1.deleteObject(employeeNested);
nestedUow1.commitAndResume();
if (employee.getPhoneNumbers().size() != 0) {
throw new TestErrorException("Objects removal from the nested unit of work is not merged into outer/main unit of work. Number of remaining objects is: " + employee.getPhoneNumbers().size());
}
}
use of org.eclipse.persistence.testing.models.employee.domain.Employee 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.Employee in project eclipselink by eclipse-ee4j.
the class NestedUnitOfWorkNewObjectWithIndirectionTest method test.
@Override
public void test() {
UnitOfWork uow = getSession().acquireUnitOfWork();
UnitOfWork nestedUow1 = uow.acquireUnitOfWork();
Employee employeeClone = (Employee) uow.registerObject(original);
Employee employeeNestedClone = (Employee) nestedUow1.registerObject(employeeClone);
if (((Employee) employeeNestedClone.getManagedEmployees().firstElement()).getManager() != employeeNestedClone) {
throw new TestErrorException("Object Identity Lost when triggering indirection in nested UOW see BUG # 3228185");
}
}
Aggregations