users@jersey.java.net

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

From: Martin Shaw <martin_at_opendev.co.uk>
Date: Tue, 31 Mar 2009 19:48:26 +0000

Hi.

I'd recommend using hyperjaxb3 - it forms the JAXB <-> objects <-> JPA
bridge very well. I've recently used it in a series of jersey projects where
I was looking to provide CRUD type functions closely linked to the data
layer via JPA.

There is one snag (or benefit, depends on familiarity) which is that
hyperjaxb is driven primarily from xml schema. For me this provides a great
solution and the integration with a maven build is very neat.

I'd think it's definitely worth a look if you haven't already evaluated that
option.

Best of luck.


Martin.

2009/3/31 Arul Dhesiaseelan <arul_at_fluxcorp.com>

> I meant you still need to put JAXB annotations on your JPA entity as well.
>
>
> Felipe Gaścho wrote:
>
>> I tought I was forced to use JAXB, but if I can expose my entities
>> directly in the resources, much better ... let me see.............
>>
>> On Tue, Mar 31, 2009 at 7:55 PM, Arul Dhesiaseelan <arul_at_fluxcorp.com>
>> wrote:
>>
>>
>>> 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
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>