Skip to main content

JAXB 2.0 and Hibernate

4 replies [Last post]
blackstar
Offline
Joined: 2005-08-10
Points: 0

Much like ibsscott asks for in http://forums.java.net/jive/thread.jspa?threadID=1128&tstart=0, how does one best use the JAX-RPC generated classes (i.e. JAXB beans) with hibernate 3 (+ or - the EJB 3.0).

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jkorho
Offline
Joined: 2005-12-08
Points: 0

What's the best practice to get Hibernate and JAXB2 work together with not-generated POJOs, any ideas?

I've an existing model that's persistentable by Hibernate. There's the plan to use JAXB 2.0 and it's annotations to marshal/unmarshal these POJOs. No generated classes involved.

The problem is how to handle LazyInitializationException when marshalling only partially initialized sub-graph of objects? It's not option to keep Hib's session open, because then the whole database will be marshalled in one query.

Is there any possibility to catch exceptions (and ignore them) while marhalling?

For now I travel through the object graph and nullify every uninitalized proxy before I execute marhalling. It works but it ain't elegant.

ibsscott
Offline
Joined: 2005-07-19
Points: 0

I found this link for using JAXB with Hibernate.

https://hyperjaxb.dev.java.net/doc/reference/en/html/

I'd like to let the JBoss container do the mapping for me and use the JAXB bean as an EJB 3.0 entity bean.

blackstar
Offline
Joined: 2005-08-10
Points: 0

Not a bad idea. Hyperjaxb only supports hibernate 2 [at this time]. I am more interested in hibernate 3 but will settle for 2 :)

lexi
Offline
Joined: 2004-04-09
Points: 0

Hyperjaxb2 supports Hibernate3.