Skip to main content

JAXB 2.0 and Hibernate

4 replies [Last post]
Joined: 2005-08-10

Much like ibsscott asks for in, 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.
Joined: 2005-12-08

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.

Joined: 2005-07-19

I found this link for using JAXB with Hibernate.

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.

Joined: 2005-08-10

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

Joined: 2004-04-09

Hyperjaxb2 supports Hibernate3.