use of org.eclipse.persistence.testing.tests.unitofwork.changeflag.model.ALCTEmployee in project eclipselink by eclipse-ee4j.
the class ALCTEmployeeSystem method populate.
/**
* This method will instantiate all of the example instances and insert them into the database
* using the given session.
*/
@Override
public void populate(DatabaseSession session) {
UnitOfWork unitOfWork = session.acquireUnitOfWork();
ALCTEmployee emp = new ALCTEmployee();
emp.setFirstName("ALCTEmp");
emp.setLastName("NotRequired");
ALCTEmploymentPeriod empPeriod = new ALCTEmploymentPeriod();
empPeriod.setEndDate(Helper.dateFromYearMonthDate(2006, 12, 2));
empPeriod.setStartDate(Helper.dateFromYearMonthDate(2004, 12, 2));
emp.setPeriod(empPeriod);
unitOfWork.registerObject(emp);
unitOfWork.commit();
}
use of org.eclipse.persistence.testing.tests.unitofwork.changeflag.model.ALCTEmployee in project eclipselink by eclipse-ee4j.
the class AggregateAttributeChangeTrackingTest method test.
@Override
protected void test() {
UnitOfWork uow = getSession().acquireUnitOfWork();
ALCTEmployee emp = (ALCTEmployee) uow.readObject(ALCTEmployee.class);
emp.getPeriod().setEndDate(new java.sql.Date(191099988948748948L));
if (emp._persistence_getPropertyChangeListener() == null) {
throw new TestErrorException("Attribute Level Change Tracking not active in aggregate");
}
if (!((AttributeChangeListener) emp._persistence_getPropertyChangeListener()).hasChanges()) {
throw new TestErrorException("Attribute Level Change Tracking not active in aggregate");
}
}
use of org.eclipse.persistence.testing.tests.unitofwork.changeflag.model.ALCTEmployee in project eclipselink by eclipse-ee4j.
the class WeakReferenceTest method test.
@Override
public void test() {
UnitOfWork uow = getSession().acquireUnitOfWork(ReferenceMode.WEAK);
int size = uow.readAllObjects(ALCTEmployee.class).size();
for (int i = 0; i < 200; ++i) {
// force cacheKey cleanup
uow.setShouldNewObjectsBeCached(true);
ALCTEmployee emp = new ALCTEmployee();
emp.setId(new BigDecimal(i));
uow.registerObject(emp);
}
try {
Long[] arr = new Long[10000000];
for (int i = 0; i < 10000000; ++i) {
arr[i] = (long) i;
}
System.gc();
try {
Thread.sleep(200);
} catch (InterruptedException ex) {
}
System.gc();
} catch (Error er) {
// ignore
}
if (((UnitOfWorkImpl) uow).getCloneMapping().size() == size) {
throw new TestErrorException("Did not release weak references.");
}
}
use of org.eclipse.persistence.testing.tests.unitofwork.changeflag.model.ALCTEmployee in project eclipselink by eclipse-ee4j.
the class ChangeTrackedWeakReferenceTest method test.
@Override
public void test() {
UnitOfWork uow = getSession().acquireUnitOfWork(ReferenceMode.FORCE_WEAK);
Collection collection = uow.readAllObjects(ALCTEmployee.class);
for (Iterator iterator = collection.iterator(); iterator.hasNext(); ) {
((ALCTEmployee) iterator.next()).setFirstName("" + System.currentTimeMillis());
}
int size = collection.size();
try {
Long[] arr = new Long[100000];
for (int i = 0; i < 100000; ++i) {
arr[i] = (long) i;
}
} catch (Error er) {
// ignore
}
if (((UnitOfWorkImpl) uow).getCloneMapping().size() != size) {
throw new TestErrorException("Released Objects with changes on weak references.");
}
}
Aggregations