Hibernate 3.0
Brief : My application uses: Flash Remoting (AMF) with Java+Hibernate. My domain objects get serialized/deserialzed via Flash Gateway. As per the design practice - we just pass the basic Domain object (i.e minus all assosiations) to & fro , barring some exceptional cases.We make the reassosiations on AS side. Though in java layer i do manuplate the whole object graph. (Cascades for each assosiation have been defined as per requirement - dont want changes here)
Case: Say, I have an object A which has a lazy association collection B (1:m) , now i go thru following steps:
1) Load A
2)Pass it to Flash //Detached state
3)Make some modifications on A
4)Pass it back to Hibernate and reassosiate it with session by update() or whatever. //Reasssocciated
5)Flush / tx.commit() // Db hit
Hibernate deletes the collection B while updating A. This is fine and exceptable since the Flash Gateway serilizes the requested object A from AS to Java , and in the process nullifies the collection which is never.
Workarounds: There are couple of things we can do but with payoffs , like link B with A (but this would cause n/w latency for obvious reasons ) , second , we can pull the same object from db (by id) and sort of overwrite it by the basic A properties , something like dynamic update (but this an extra round trip)
Issue:
1) Is there a better solution? am i missing on something ?
2) Can we ask Hibernate to reattach an object forcefully without a dirty check - this might also be useful for the users interested in different clients /rich clients (otherthan -java or .Net) which would also function in the similar fashion and have own native way of serializaation/deserialization of object graphs.
|