Each is a bean (POJO) persisted using Hibernate.
The PendingCat table is used to store incomplete records. Database constraints would not allow them to be stored in the Cat table.
Retrieve a PendingCat record from the database, deserialize it to create an instance of a Cat, make updates, then either update the PendingCat table (if validation fails) or create a new Cat record (when validation passes).
Add a transient Cat property to the PendingCat bean. In the set method of the Cat property serialize it and update the serializedCat property. In the set method of the serializedCat property deserialize it and update the Cat property. (Updates are done by updating the private variable, not calling the set methods and creating an infinite loop.) Serializing and deserializing is done using java.beans.XMLEncoder and java.beans.XMLDecoder.
When the Cat instance is created by deserializing the Kitten set is a PersistentSet. As soon as it is accessed the infamous LazyInitializationException is thrown. I haven't been able to attach it to a session because I get the "an object with that ID already exists" error. It seems like somehow I have a partially attached object. Any ideas (other than eliminating serialization)?
posted 11 years ago
In case anyone else is looking for a solution to this, I've implemented Giliead. From their site:
Gilead stands for Generic Light Entity Adapter
It permits you to send Persistent entities (and especially the partially loaded ones) outside the JVM (GWT, Flex, Web-Services, ...) without pain.