Hi Adam,
Good to hear. I have just updated the JPA/JAXB example (see link
below) to include the bidirectional OXM relationship mapping support
we've added to EclipseLink 2.0. Next I will add updates for composite
keys and embedded key classes, are you using either of these concepts
in your model?
http://wiki.eclipse.org/EclipseLink/Examples/MOXy/JPA
-Blaise
Adam Stroud wrote:
Blaise:
I actually just stumbled upon the schema generation functionality. I
will give that a try and see how far I get.
Thanks
Adam
Blaise Doughan wrote:
Hi Adam,
You are correct, the JAXB annotations will allow you to map the JPA
entity classes to XML. This will require you only have one Java model.
You can generate an XML schema from annotated Java classes using the
generateSchema(SchemaOutputResolver) method on JAXBContext:
* http://java.sun.com/javase/6/docs/api/javax/xml/bind/JAXBContext.html#generateSchema(javax.xml.bind.SchemaOutputResolver)
Using EclipseLink 2.0 JAXB you will also be able to:
* Map bidirectional relationships using @XmlInverseReferece
* Use composite keys in key based XML relationships
* Map JPA entites with embedded key classes
* Use the @XmlID annotation on non-String fields and Properties
-Blaise
Adam Stroud wrote:
Blaise:
Thanks for the reply. I have not come across any issues yet as I have
just started development. I am developing a RESTful web service that
will receive XML that will need to be mapped to JPA entities that will
be persisted. My initial thought was to create an XSD to define the web
service traffic, and run JAXB over this to create Java classes. I would
then define the entities to be persisted and manually write the code to
convert the XML to the entities. This just didnt feel right so I
started to see if there was a better way. It seems that the JAXB
annotations might be what I am looking for. From what I have seen thus
far, I will be able to both marshal and unmarshal the XML into my
entities. The only feature I would still like to have is the XSD. It
does not look like I can generate an XSD from JAXB annotated classes.
So, if I want the XSD it looks like I need to maintain multiple models.
Any other ideas?
Thanks
Adam
Blaise Doughan wrote:
Hi Adam,
My apologies for not getting back to the thread. If you let me know the
issues you are encountering I will help you out.
You should be able to do this in one model. Below is a link to an
example I am working on to do just what you are describing with the
EclipseLink 2.0 APIs:
* http://wiki.eclipse.org/EclipseLink/Examples/MOXy/JPA
It is still a work in progress, some other things you will find useful:
* /*Bidirectional Relationship Support*/
Today we will be checking in an XMLInvereseReferenceMapping, this
mapping will allow you map back pointers.
* /*Composite Key Support*/
EclipseLink 2.0 now supports composite keys on all the key based
mappings. I still need to update the example with this.
-Blaise
Adam Stroud wrote:
All:
I am developing an application that uses Eclipselink both JAXB (Moxy)
and JPA. My question is what is the best way to go from my current
data model to entities and XML without maintaining three different
models. I saw an earlier post to the mailing list here ->
http://dev.eclipse.org/mhonarc/lists/eclipselink-users/msg03473.html,
but it does not look like the examples referenced in the reply were
posted to the list. Any input/guidance would be appreciated.
Thanks
Adam
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
|