/** */
private void createObjects(PersistenceManager pm) {
Transaction tx = pm.currentTransaction();
tx.begin();
Company comp = new Company(1L, "Sun Microsystems", new Date(), new Address(0,"","","","",""));
//Add transient departments
dep1 = new Department(1L, "Department 1");
dep2 = new Department(2L, "Department 1");
dep3 = new Department(3L, "Department 1");
comp.addDepartment(dep1);
comp.addDepartment(dep2);
comp.addDepartment(dep3);
pm.makePersistent(comp); //Now the transient departments should be made provisionally persistent via reachability
int curr = currentState(dep1);
if( curr != PERSISTENT_NEW ){
fail(ASSERTION_FAILED, "dep1 should be persistent-new, state is " + states[curr]);
}
curr = currentState(dep2);
if( curr != PERSISTENT_NEW ){
fail(ASSERTION_FAILED, "dep2 should be persistent-new, state is " + states[curr]);
}
curr = currentState(dep3);
if( curr != PERSISTENT_NEW ){
fail(ASSERTION_FAILED, "dep3 should be persistent-new, state is " + states[curr]);
}
//Remove departments
comp.removeDepartment(dep1);
comp.removeDepartment(dep2);
comp.removeDepartment(dep3);
tx.commit(); //Now the removed departments should be made transient again
}