|
[
Permalink
| « Hide
]
Costin Leau added a comment - 14/Jun/05 07:11 AM
converter
I found this more comprehensive solution only after I'd written my own. I'd love for this to be included in the main xstream distro, it's probably going to be a very common use case.
Question while I'm at it - anyone done any work on handling proxy classes decorated by cglib by hibernate? The simple solution would be to simply disable them, but lazy loading of fields is occasionally a big big win, so I'm reluctant to go down that road. I've seen your comment only now - I didn't had any watches placed on. I'm glad you like the solution.
I have done some work on decorated classes some time ago and I can donate some code if there is such a need. If you are in need of a quick fix make a mapper that removes the signature of CGLIB. After struggling with the HB api I stopped working on the tests. PersistentCollections & Co. are highly connected to HB API and to me it seems almost impossible (you have to create the whole internal HB hierarchy with dummy objects that in the end do not work).
I've added a mapper for CGLIB enhanced classes: http://jira.codehaus.org/browse/XSTR-238
Also see http://forum.hibernate.org/viewtopic.php?t=939007&highlight=xstream
I just reopen the issue, since the HIbernate problem is not solved, but asked at a constant rate. So the issue will not get lost, even if the donated code might not solve any issue.
The following line of code might be incorrect in the HibernateCollectionConverter
// the set is returned as a map by Hibernate (unclear why exactly) ((HashMap)collection).entrySet() will return a set of Map.Entry and not the value which I think is what we want. Maybe it should be something like: } Another approach here is to integrate functionality provided by beanlib to make this problem go away.
http://beanlib.sourceforge.net/ Hibernate3BeanReplicator().deepCopy() handles two issues with hibernate:
Of course this deep copy is not very efficient if you do it in addition to XStream's traversal of the object. Ideally this would be handled internally as XStream is traversing. Other than converting the Hibernate collection type as Java standard collection types, is there any other benefit of this converter (And why should one need to do that) ? If I'm not wrong, It does not facilitate serializing hibernate lazy loaded classes.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||