Prabhjot
Prabhjot

Reputation: 704

Any special considerations while converting hibernate objects directly to XML

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

Answers (3)

Prabhjot
Prabhjot

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

Arash
Arash

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

Related Questions