public void populate(DatabaseSession session) { Employee instance; PopulationManager manager = PopulationManager.getDefaultManager(); instance = Employee.example1(); session.writeObject(instance); manager.registerObject(instance, "example1"); manager.registerObject(instance.computer, "example1"); manager.registerObject(instance.shipments.firstElement(), "example1"); manager.registerObject( ((Shipment) instance.shipments.firstElement()).orders.firstElement(), "example1"); instance = Employee.example2(); session.writeObject(instance); manager.registerObject(instance, "example2"); manager.registerObject(instance.computer, "example2"); manager.registerObject(instance.shipments.firstElement(), "example2"); manager.registerObject( ((Shipment) instance.shipments.firstElement()).orders.firstElement(), "example2"); instance = Employee.example3(); session.writeObject(instance); manager.registerObject(instance, "example3"); manager.registerObject(instance.computer, "example3"); manager.registerObject(instance.shipments.firstElement(), "example3"); manager.registerObject( ((Shipment) instance.shipments.firstElement()).orders.firstElement(), "example3"); }
public void test() { UnitOfWork uow = getSession().acquireUnitOfWork(); this.emp = Employee.example1(); this.emp.asset1.asset = Vehicle.example1(); uow.registerObject(this.emp); uow.commit(); uow = getSession().acquireUnitOfWork(); Employee empClone = (Employee) uow.registerObject(this.emp); Employee newClone = (Employee) empClone.clone(); ((Vehicle) newClone.asset1.asset).make = "Beamer"; uow.deepMergeClone(newClone); uow.commit(); if (!((AbstractSession) getSession()).compareObjects(newClone, this.emp)) { throw new TestErrorException("Failed to merge the Variable 1 to 1 properly"); } }