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)));
}
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");
}
}
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");
}
}
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");
}
}
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();
}
Aggregations