Here is the scenerio.
1. A standalone client program loads a list of DistributionPlan objects. This is accomplished by calling a SSB which creates a new Hibernate Session object which is used to create a Query which then returns the list of object via the list() method.
2. The client program then presents a DistributionObject to the user for manipulation. When the user is done he/she clicks save which sends the DistributionPlan in question over the network to another SSB which includes the following code.
Code:
//hack to get the shipment to refresh properly
Map products = new HashMap(plan.getProducts());
plan.setProducts(products);
Map regionQuantities = new HashMap(plan.getRegionQuantities());
plan.setRegionQuantities(regionQuantities);
Set shipments = new HashSet(plan.getShipments());
plan.setShipments(shipments);
Iterator shipmentProcessor = shipments.iterator();
while(shipmentProcessor.hasNext()) preProcessShipment((Shipment)shipmentProcessor.next());
database.save(plan);
return plan;
This is the relavant portion of the database.save() call listed above.
Code:
try
{
openSession();
session.saveOrUpdate(data);
session.flush();
}
catch(Exception e)
{
e.printStackTrace();
sessionContext.setRollbackOnly();
throw new DataManagerException(e);
}
finally
{
closeSession();
}
The DistributionPlan is then returned to the client for further editing. The second time the client presses the save button, which triggers the above code on the server, changes made to objects linked to the DistributionPlan are not saved. Changes made to primitive properties of the DistributionPlan itself are always saved.
I would like to try not to change the hashCode and equals implementations of my objects. I have spent many hours testing them and have come up with implementations that do not cause recursion problems when checking collection properties but still provide accurate comparisons. I am afraid that changes to these methods will cause other parts of the program to break.
Any suggestions or advice, particularly comments that help me understand what is going on, would be appreciated.
John