use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class MultipleUnitOfWorkTest method changeFirstUnitOfWorkWorkingCopy.
protected void changeFirstUnitOfWorkWorkingCopy() {
Employee employee = (Employee) this.firstUnitOfWorkWorkingCopy;
// Transformation
employee.setNormalHours(new java.sql.Time[3]);
employee.setStartTime(Helper.timeFromHourMinuteSecond(2, 2, 2));
employee.setEndTime(Helper.timeFromHourMinuteSecond(2, 2, 2));
// Aggregate
employee.setPeriod(new org.eclipse.persistence.testing.models.employee.domain.EmploymentPeriod(Helper.dateFromYearMonthDate(1903, 3, 3), Helper.dateFromYearMonthDate(1904, 4, 4)));
// One to many private
employee.setPhoneNumbers(new Vector());
employee.addPhoneNumber(new org.eclipse.persistence.testing.models.employee.domain.PhoneNumber("home", "514", "2263374"));
employee.addPhoneNumber(new org.eclipse.persistence.testing.models.employee.domain.PhoneNumber("office", "509", "8224599"));
}
use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class NestedUOWWithNewObjectRegisteredTwiceTest method test.
@Override
public void test() {
Employee empRO = (Employee) getSession().readObject(Employee.class, new ExpressionBuilder().get("firstName").equal(firstName));
// start transaction T0
UnitOfWork uowT0 = getSession().acquireUnitOfWork();
Employee empT0 = (Employee) uowT0.registerObject(empRO);
// create phone number and commit in a nested unit of work
UnitOfWork uowT01 = uowT0.acquireUnitOfWork();
Employee empT01 = (Employee) uowT01.registerObject(empT0);
PhoneNumber pN = (PhoneNumber) uowT01.registerObject(new PhoneNumber());
pN.setAreaCode(areaCode);
empT01.addPhoneNumber(pN);
uowT01.commit();
// the phone number is a new object in uowT0
PhoneNumber pNT0 = (PhoneNumber) empT0.getPhoneNumbers().get(0);
// start another nested unit of work
UnitOfWork uowT02 = uowT0.acquireUnitOfWork();
uowT02.setShouldNewObjectsBeCached(true);
// load empT0 from the parent cache and clone and register it
Employee empT02 = (Employee) uowT02.registerObject(empT0);
// get detail via relation. this will trigger the value holder and clone and register phone number in uowT02
pNT02REL = (PhoneNumber) empT02.getPhoneNumbers().get(0);
// get detail via registration. this should return the same clone as referenced by pNT02REL
pNT02REG = (PhoneNumber) uowT02.registerObject(pNT0);
uowT0.commit();
}
use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class NewObjectIdentityTest method test.
@Override
public void test() {
UnitOfWork uow = getSession().acquireUnitOfWork();
origPerson = new Employee();
Employee person = (Employee) uow.registerObject(origPerson);
person.setFirstName("Anthony");
person.setLastName("Anthony");
((UnitOfWorkImpl) uow).issueSQLbeforeCompletion();
Runnable runnable = new Runnable() {
@Override
public void run() {
ReadAllQuery query = new ReadAllQuery(Employee.class);
query.setSelectionCriteria(query.getExpressionBuilder().get("firstName").equal("Anthony").and(query.getExpressionBuilder().get("lastName").equal("Anthony")));
readPerson = (Employee) ((Vector) getSession().executeQuery(query)).firstElement();
}
};
Thread thread = new Thread(runnable);
thread.start();
try {
Thread.sleep(3000);
} catch (InterruptedException ex) {
}
((UnitOfWorkImpl) uow).mergeClonesAfterCompletion();
try {
thread.join();
} catch (InterruptedException ex) {
}
}
use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class NoValidationWithInitIdentityMaps method testNoneCheckDatabase.
public void testNoneCheckDatabase() {
Employee employeeFromCache = (Employee) getSession().readObject(Employee.class);
// initialize Identity map to verify toplink will perform an existence check
getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
getSession().getDescriptor(Employee.class).setExistenceChecking("Check database");
UnitOfWork uow = getSession().acquireUnitOfWork();
Employee newObject = (Employee) uow.newInstance(Employee.class);
this.objectToBeWritten = newObject;
uow.dontPerformValidation();
newObject.setManager(employeeFromCache);
uow.commit();
}
use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class NoValidationWithInitIdentityMaps method testNoneAssumeExistence.
public void testNoneAssumeExistence() {
Employee employeeFromCache = (Employee) getSession().readObject(Employee.class);
// initialize Identity map to verify toplink will perform an existence check
getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
getSession().getDescriptor(Employee.class).setExistenceChecking("Assume existence");
UnitOfWork uow = getSession().acquireUnitOfWork();
Employee newObject = (Employee) uow.newInstance(Employee.class);
this.objectToBeWritten = newObject;
uow.dontPerformValidation();
newObject.setManager(employeeFromCache);
uow.commit();
}
Aggregations