[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3840?page=c...
]
Alexander Rau commented on HHH-3840:
------------------------------------
Another important use-case: copying/cloning persistent single objects or even whole object
trees
Found dozens of more or less unresolved postings. Here one of them serving as an example:
http://forum.hibernate.org/viewtopic.php?p=2247235#2247235
http://forum.hibernate.org/viewtopic.php?t=933054&highlight=evict+col...
Interestingly people are trying to workaround a lot and getting other errors as a
consequence. I think implementing this improvement potentially could avoid loads of other
problems and questions due to the failing workarounds.
Retrieving cleaned objects from hibernate and saving them again would result in such a
copy as far as I can see (same object state from an application point of view + new
assigned internal identifier). Dangling hibernate management properties in persistent
collections would (and actually do) cause severe errors here. That's why people again
try to get rid of that data in other ways (e.g. by using this ... strange... beanlib
library:
http://beanlib.sourceforge.net/ ).
Alex
Export non-infected object trees without collection wrappes
-----------------------------------------------------------
Key: HHH-3840
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3840
Project: Hibernate Core
Issue Type: Improvement
Reporter: Alexander Rau
There has been lots of discussion on the web about "getting rid" of hibernate
classes inside a loaded object tree so it seems like there is a notable demand for
improvement here.
Two real-world use cases where obtaining a "non-infected" object tree from a
session IMHO should be possible and would help a lot:
1) Exporting an eagerly loaded object model to XML with 3rd party libraries by using
reflection (e.g. xstream): Workaround proposals in general perform a cleaning on the
object model *after* receiving it from the session. Either traversing the object tree
"on their own" and replacing the hibernate collection wrappers with their
original java.util.* classes or post-processing generated xml and filtering out
hibernate-specific tags. It would be clearly simpler and less error prone if hibernate
would help here already (imagine cleaning an object tree with circular/bidirectional
references and dozens of collections !). Furthermore this clearly shows the conflict here:
first hibernate injects collections wrappers and the application code immediately tries
to get rid of them.
2) (Web-layer) Session persistence: Increased amount of space consumed as the collection
wrappers need to be persisted as well even when it's clear that the objects won't
be used again for updating data via hibernate (e.g. read-only views). Again
application-level clean out code is required if hibernate does not help in getting a clean
model.
There are certainly more use cases.
The described problems could be nicely solved in a general manner and remove the burden
of the application programmer of post-cleaning tasks if the hibernate session would allow
to retrieve "clean" objects (by introducing a new method session.export(..) for
example which could be similar to session.load(..) ). Session.export(..) would then return
the object tree without collection wrappers but instead with their original collection
pendants.
This would perfectly fit the concept of persisting new objects. The state of an exported
object would be exactly the same as the state of a new object which has not yet been
passed to the hibernate layer.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira