users@jaxb.java.net

jaxb 2.0, schemagen

From: jeff <jeffrey.blattman_at_yahoo.com>
Date: Fri, 23 Feb 2007 17:15:09 -0800 (PST)

hello,

i am hoping someone here can explain the best way to handle this situation ...

we want to have a set of classes that are both JPA persistable and XML marshal/unmarshalable. so, for example, i can create an object from an XML document, persist that object using JPA. and vice versa, load an object using JPA, and then export it as XML.

so, for example, is this the best approach?

1. define JPA entity classes
2. use schemagen to generate XSD from those classes
3. use XJC to compile the XSD
4. have some custom code that converts JAXB-generated classes into JPA entity classes, and vice versa

i don't like step 4 obviously. so another option ...

1. define XSD
2. use XJC to compile the XSD
3. modify the generated sources manually to add JPA annotations

this seems wrong though, because for example if in jaxb 2.next the annotations change, i imagine i'd have to re-compile the XSD and add back in the JPA annotations manually. this sort of violates a cardinal rule: thow shalt never commit generated source files.

thanks much.



 
---------------------------------
The fish are biting.
 Get more visitors on your site using Yahoo! Search Marketing.