users@jersey.java.net

Re: [Jersey] JPA -> JAXB -> XML/JSON ??

From: Arul Dhesiaseelan <arul_at_fluxcorp.com>
Date: Tue, 31 Mar 2009 11:55:34 -0600

Felipe Gaúcho wrote:
> then I have the persistence layer based on JPA (@Entity).. and I need
> JAXB annotated types in order to serialize them through my Jersey
> resources ....
>
> how do you do this conversion ?
>
> design alternatives also helps.. in case Jersey is not designed to
> work on top of a persistence layer.............
>
>
You could see the bookmark example which uses JPA and JSON. You could
easily change it to use JAXB.
I prefer to avoid conversion at various layers, so you could probably
annotate your JPA entity using JAXB. But, it all depends how you want to
expose your model to the users. In my case, I had to add @XmlTransient
for some of the data which should not be exposed to users.

HTH,
-Arul