Serializing Hibernate objects as XML using XStream
People have been looking for serializing Hibernate as XML using XStream, a task that is not straightforward.
I designed a solution that I would like to share with the open source community, called xstream-for-pojo.
It seams a quite simple approach at the beginning. Until you discover that Hibernate injected a lot of additional fields into your original objects and that sometimes Hibernate exchanges your original objects with proxies. Even worse, data may not yet be loaded on fields declared as lazy. Hibernate collections are even more complicated.
For a long time people were already ordering to get out of one’s POJO. Many similar solutions were proposed, like setting converters and default implementations (I also posted a comment on this solution) for some specific Hibernate classes. People have been discussing on forums years ago, already. The there were already filed some requests for enhancements on XStream issue tracker, where some fixes are proposed. The solution I most liked is undoing the proxies.
All the approaches present interesting ideas, but none of them convinced me as a complete solution. Suddenly, I realized a solution that covers practically all cases where Hibernate will cause trouble for XStream.
I would like to invite you to take a look on my open source project on http://code.google.com/p/xstream-for-beans. Feedback is welcome. The idea behind the solution is described on the project wiki.

