Reputation: 704
I'm trying to convert to list of hibernate objects to XML using JAXB. Are there any special considerations OR any reasons a list of hibernate objects with one to many relationship can't be converted?
1.) It seems like PersistentSet provided by Hibernate is not Serializable and hence, can't be converted by JAXB. I would probably would need to cast it to a "Serializable" set. Is this correct? If yes, how do I achieve it?
Edit 1. I'm going to write Set adapter class, similar to this example link. Will update my findings. http://www.objectpartners.com/2010/01/25/using-jpa-and-jaxb-annotations-in-the-same-object/
As mentioned below, there is no need to convert PersistentSet as it is serializable already.
Edit 2 (and Solution). Ok, I'm able to able to make it work.Thanks to Maven's Schemagen which gave the hint that 'java.sql.TimeStamp' is not compatible with JAXB. I wrote an adaptor which converts TimeStamp to Date.
Thanks everyone for guiding on this.
Upvotes: 2
Views: 821
Reputation: 704
I'm able to able to make it work.Thanks to Maven's Schemagen which gave the hint that 'java.sql.TimeStamp' is not compatible with JAXB. I wrote an adaptor which converts TimeStamp to Date.
Upvotes: 0
Reputation: 12425
Why don't you use hibernates xml store? It is much easier. http://docs.jboss.org/hibernate/core/3.3/reference/en/html/xml.html
Upvotes: 1
Reputation: 1239
PersistentBag and PersistenceSet, both are serializable. See http://docs.jboss.org/hibernate/core/3.2/api/org/hibernate/collection/PersistentSet.html and http://docs.jboss.org/hibernate/core/3.2/api/org/hibernate/collection/PersistentBag.html
Upvotes: 5