[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3840) Export non-infected object trees without collection wrappes

Alexander Rau (JIRA) noreply at atlassian.com
Sun Mar 29 10:47:38 EDT 2009


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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list