users@jersey.java.net

Re: [Jersey] Converter list problem

From: Erdinc Yilmazel <erdinc_at_yilmazel.com>
Date: Sat, 14 Mar 2009 10:59:41 +0000

You should have a collection of MyThingConverter in your
MyThingsConverter class.

public class MyThingsConverter {
   private Collection<MyThing> entities; ---> private
Collection<MyThingConverter> entities;

I am assuming that you have getter and setter methods for these
properties in MyThingsConverter class.
If your getter is returning Collection<MyThing>, Jaxb wouldn't care
about XmlRootElement annotation in MyThingConverter.
You should either return a collection of MyThingConverter or you
should also add XmlRootElement annotation to you your
JPA entity.



On Sat, Mar 14, 2009 at 3:41 AM, Gautam Arora <gautamsarora_at_gatech.edu> wrote:
>
> MyThing is an entity class and is annotated with the required JPA annotations
> like:
> @Entity
> @Table(name = "my_thing")
> @NamedQueries(...)
> public class MyThing {
> ...
> }
>
> Should the JPA annotations matter here because this seems to be an issue in
> the handling of Converter (JAXB) annotations...
>
>
>
> Erdinc Yilmazel wrote:
>>
>> How is your MyThing class annotated?
>>
>> On Sat, Mar 14, 2009 at 2:22 AM, Gautam Arora <gautamsarora_at_gatech.edu>
>> wrote:
>>>
>>> Hi,
>>> I have a Converter structure similar to....
>>>
>>> @XmlRootElement(name = "things")
>>> public class MyThingsConverter {
>>>    private Collection<MyThing> entities;
>>>    private Collection<MyThingConverter> items;
>>> .....
>>> }
>>>
>>> @XmlRootElement(name = "thing")
>>> public class MyThingConverter {
>>>    private MyThing entity;
>>> ...
>>> }
>>>
>>> now when i get a response using MyThingsConverter (by returning an object
>>> of
>>> it), my response looks like:
>>> <things>
>>>    <MyThing>
>>>    ....
>>>    </MyThing>
>>> </things>
>>>
>>> whereas I am expecting it to be:
>>> <things>
>>>    <thing>
>>>    ....
>>>    </thing>
>>> </things>
>>>
>>> so it seems that the MyThingsConverter is not properly picking up the
>>> correct XmlRootElement for thing which is defined by me as thing and
>>> going
>>> with the default class name of MyThing.
>>>
>>> When I just try to get a reponse from MyThingConverter, I get
>>> <thing>
>>> ...
>>> </thing>
>>>
>>> So, the problem seems to be when MyThingsConverter contains a list
>>> MyThingConverter.
>>>
>>> Any flag/setting that I need to enable in such a case?
>>>
>>> Thanks,
>>> Gautam
>>> --
>>> View this message in context:
>>> http://n2.nabble.com/Converter-list-problem-tp2476841p2476841.html
>>> Sent from the Jersey mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>>
>
> --
> View this message in context: http://n2.nabble.com/Converter-list-problem-tp2476841p2476981.html
> Sent from the Jersey mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>