Search in sources :

Example 16 with Employee

use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.

the class DeepNestedUnitOfWorkTest method changeFirstLevelUnitOfWorkWorkingCopy.

protected void changeFirstLevelUnitOfWorkWorkingCopy() {
    Employee employee = (Employee) this.unitOfWorkWorkingCopy[0];
    // Transformation
    employee.setNormalHours(new java.sql.Time[2]);
    employee.setStartTime(Helper.timeFromHourMinuteSecond(1, 1, 1));
    employee.setEndTime(Helper.timeFromHourMinuteSecond(1, 1, 1));
    // Aggregate
    employee.setPeriod(new EmploymentPeriod(Helper.dateFromYearMonthDate(1901, 1, 1), Helper.dateFromYearMonthDate(1902, 2, 2)));
}
Also used : EmploymentPeriod(org.eclipse.persistence.testing.models.employee.domain.EmploymentPeriod) Employee(org.eclipse.persistence.testing.models.employee.domain.Employee)

Example 17 with Employee

use of org.eclipse.persistence.testing.models.employee.domain.Employee 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 18 with Employee

use of org.eclipse.persistence.testing.models.employee.domain.Employee 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 19 with Employee

use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.

the class ExceptionsRaisedUnitOfWorkTest method test.

@Override
public void test() {
    // Read some object from the database.
    boolean exceptionCaught = false;
    Employee employee = (Employee) getSession().readAllObjects(Employee.class).firstElement();
    UnitOfWork firstUOW = getSession().acquireUnitOfWork();
    // Read some object from the database.
    Vector employees = firstUOW.readAllObjects(Employee.class);
    Employee uowEmployee = (Employee) employees.elementAt(2);
    uowEmployee.setAddress(employee.getAddress());
    // commit the unit of work
    try {
        firstUOW.commit();
    } catch (QueryException exception) {
        exceptionCaught = true;
    }
    if (!exceptionCaught) {
        throw new TestErrorException("Performed illegal operations in UOW yet no exception was thrown");
    }
}
Also used : UnitOfWork(org.eclipse.persistence.sessions.UnitOfWork) QueryException(org.eclipse.persistence.exceptions.QueryException) Employee(org.eclipse.persistence.testing.models.employee.domain.Employee) TestErrorException(org.eclipse.persistence.testing.framework.TestErrorException) Vector(java.util.Vector)

Example 20 with Employee

use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.

the class FaultyUnitOfWorkTest method setup.

@Override
protected void setup() {
    getAbstractSession().beginTransaction();
    // Read some object from the database.
    this.employeeInSession = (Employee) getSession().readAllObjects(Employee.class).firstElement();
    this.addressOfEmployeeInSession = employeeInSession.getAddress();
    this.addressOfEmployeeInSession.setCity("LKO");
    Employee employee = (Employee) getSession().readAllObjects(Employee.class).lastElement();
    this.anotherAddress = employee.getAddress();
}
Also used : Employee(org.eclipse.persistence.testing.models.employee.domain.Employee)

Aggregations

Employee (org.eclipse.persistence.testing.models.employee.domain.Employee)220 UnitOfWork (org.eclipse.persistence.sessions.UnitOfWork)79 TestErrorException (org.eclipse.persistence.testing.framework.TestErrorException)52 ExpressionBuilder (org.eclipse.persistence.expressions.ExpressionBuilder)40 Vector (java.util.Vector)34 ReadObjectQuery (org.eclipse.persistence.queries.ReadObjectQuery)32 SmallProject (org.eclipse.persistence.testing.models.employee.domain.SmallProject)29 Address (org.eclipse.persistence.testing.models.employee.domain.Address)24 PhoneNumber (org.eclipse.persistence.testing.models.employee.domain.PhoneNumber)22 Expression (org.eclipse.persistence.expressions.Expression)21 LargeProject (org.eclipse.persistence.testing.models.employee.domain.LargeProject)18 UnitOfWorkImpl (org.eclipse.persistence.internal.sessions.UnitOfWorkImpl)16 TestSuite (org.eclipse.persistence.testing.framework.TestSuite)15 PopulationManager (org.eclipse.persistence.tools.schemaframework.PopulationManager)15 ReadAllQuery (org.eclipse.persistence.queries.ReadAllQuery)14 Project (org.eclipse.persistence.testing.models.employee.domain.Project)14 EmployeePopulator (org.eclipse.persistence.testing.models.employee.domain.EmployeePopulator)11 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)9 ValidationException (org.eclipse.persistence.exceptions.ValidationException)9 EmploymentPeriod (org.eclipse.persistence.testing.models.employee.domain.EmploymentPeriod)9