Search in sources :

Example 1 with EmployeePopulator

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");
    }
}
Also used : UnitOfWork(org.eclipse.persistence.sessions.UnitOfWork) Employee(org.eclipse.persistence.testing.models.employee.domain.Employee) EmployeePopulator(org.eclipse.persistence.testing.models.employee.domain.EmployeePopulator) ReadObjectQuery(org.eclipse.persistence.queries.ReadObjectQuery) TestErrorException(org.eclipse.persistence.testing.framework.TestErrorException) UnitOfWorkImpl(org.eclipse.persistence.internal.sessions.UnitOfWorkImpl) BigDecimal(java.math.BigDecimal)

Example 2 with EmployeePopulator

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");
    }
}
Also used : UnitOfWork(org.eclipse.persistence.sessions.UnitOfWork) Employee(org.eclipse.persistence.testing.models.employee.domain.Employee) EmployeePopulator(org.eclipse.persistence.testing.models.employee.domain.EmployeePopulator) ReadObjectQuery(org.eclipse.persistence.queries.ReadObjectQuery) TestErrorException(org.eclipse.persistence.testing.framework.TestErrorException) UnitOfWorkImpl(org.eclipse.persistence.internal.sessions.UnitOfWorkImpl) BigDecimal(java.math.BigDecimal)

Example 3 with EmployeePopulator

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");
    }
}
Also used : UnitOfWork(org.eclipse.persistence.sessions.UnitOfWork) Employee(org.eclipse.persistence.testing.models.employee.domain.Employee) EmployeePopulator(org.eclipse.persistence.testing.models.employee.domain.EmployeePopulator) ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery) TestErrorException(org.eclipse.persistence.testing.framework.TestErrorException) UnitOfWorkImpl(org.eclipse.persistence.internal.sessions.UnitOfWorkImpl) Vector(java.util.Vector) BigDecimal(java.math.BigDecimal)

Example 4 with EmployeePopulator

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");
    }
}
Also used : UnitOfWork(org.eclipse.persistence.sessions.UnitOfWork) Employee(org.eclipse.persistence.testing.models.employee.domain.Employee) EmployeePopulator(org.eclipse.persistence.testing.models.employee.domain.EmployeePopulator) TestErrorException(org.eclipse.persistence.testing.framework.TestErrorException)

Example 5 with EmployeePopulator

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);
}
Also used : Employee(org.eclipse.persistence.testing.models.employee.domain.Employee) EmployeePopulator(org.eclipse.persistence.testing.models.employee.domain.EmployeePopulator)

Aggregations

EmployeePopulator (org.eclipse.persistence.testing.models.employee.domain.EmployeePopulator)15 Employee (org.eclipse.persistence.testing.models.employee.domain.Employee)11 TestErrorException (org.eclipse.persistence.testing.framework.TestErrorException)7 UnitOfWork (org.eclipse.persistence.sessions.UnitOfWork)6 UnitOfWorkImpl (org.eclipse.persistence.internal.sessions.UnitOfWorkImpl)4 BigDecimal (java.math.BigDecimal)3 Vector (java.util.Vector)3 InsertObjectTest (org.eclipse.persistence.testing.framework.InsertObjectTest)3 TestSuite (org.eclipse.persistence.testing.framework.TestSuite)3 ReadObjectQuery (org.eclipse.persistence.queries.ReadObjectQuery)2 EmploymentPeriod (org.eclipse.persistence.testing.models.employee.domain.EmploymentPeriod)2 PhoneNumber (org.eclipse.persistence.testing.models.employee.domain.PhoneNumber)2 OptimisticLockException (org.eclipse.persistence.exceptions.OptimisticLockException)1 ReadAllQuery (org.eclipse.persistence.queries.ReadAllQuery)1 TestWarningException (org.eclipse.persistence.testing.framework.TestWarningException)1 Address (org.eclipse.persistence.testing.models.employee.domain.Address)1 SmallProject (org.eclipse.persistence.testing.models.employee.domain.SmallProject)1