Hi,
I've recently had this issue during the migration of an application from hibernate 2 to hibernate 3, which I want to discuss on this forum with other Hibernate users:
I implemented the following form of entity serialization: during serialization, I write only the entity id (primary key) on the stream. For deserialization, I implement readResolve(), in which I get the current hibernate session, and get the entity based on the serialized primary key. This way, I have a clean serialization mechanism, not needing to bother with locking the entity with the session after deserialization, etc.
This mechanism worked fine for me with hibernate 2. However, with hibernate 3 I run into the following situation: if the entity has an unitialized proxy (e.g. was obtained through session.load), only the proxy gets serialized, without being initialized first. At deserialization, the proxy gets deserialized, but without readResolve being called, and the proxy is obviously not linked to the current session.
From my point of view, this is a bug in hibernate 3, as the proxy is not as transparent as it should be. I tried filling a bug report on this issue, but it was rejected (
http://opensource2.atlassian.com/projects/hibernate/browse/HHH-1443).
What do you think? Is this really an issue with Hibernate 3, or not?
And does anybody have a sugestion for a workaround to achieve the serialization mechanism I described (and which worked in hibernate 2)?