You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Massimo Ugues <m....@gmail.com> on 2011/03/31 15:34:58 UTC

Struts2 json plugin problem with jpa entity

Hallo all.
I have a strange issue described here:
http://stackoverflow.com/questions/5497037/struts-json-plugin-problem-serializing-jpa-entity

<http://stackoverflow.com/questions/5497037/struts-json-plugin-problem-serializing-jpa-entity>Any
idea?
Kind regards

Massimo

-- 
Massimo Ugues
http://m4zi.wordpress.com/
jabber: m.ugues@gmail.com
skype: m.ugues

Re: Struts2 json plugin problem with jpa entity

Posted by Michal Ciasnocha <mc...@struts.cz>.
Hi Massimo,

it might be similar problem with combination JPA and GWT. Read something 
about this on google code 
http://code.google.com/webtoolkit/articles/using_gwt_with_hibernate.html 
(section Why Hibernate Objects ...). One solution is use own Data 
Transfer Objects.


Regards,

Michal

Massimo Ugues wrote on 31.3.2011 15:34:
> Hallo all.
> I have a strange issue described here:
> http://stackoverflow.com/questions/5497037/struts-json-plugin-problem-serializing-jpa-entity
>
> <http://stackoverflow.com/questions/5497037/struts-json-plugin-problem-serializing-jpa-entity>Any
> idea?
> Kind regards
>
> Massimo
>

Re: Struts2 json plugin problem with jpa entity

Posted by Maurizio Cucchiara <ma...@gmail.com>.
Try this one:

@Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Beneficiario that = (Beneficiario) o;

        if (idBeneficiario != null ?
!idBeneficiario.equals(that.idBeneficiario) : that.idBeneficiario !=
null)
            return false;

        return true;
    }

On 31 March 2011 17:20, Massimo Ugues <m....@gmail.com> wrote:
> Hallo Maurizio.
> I tried to create an instance of that class (Beneficiario) in a detached
> way, but the problem persist.
> The action is created via spring
> <bean id="beneficiarioAction" scope="prototype"
> class="it.alten.beneficiario.BeneficiarioAction">
> <property name="beneficiarioDao" ref="beneficiarioDaoJpa" />
>     </bean>
> Could it be a problem?
> I think the problem is the Beneficiario class, but to me it seems to be a
> Pojo as any other.
> Kind regards
> Massimo
> On Thu, Mar 31, 2011 at 4:50 PM, Maurizio Cucchiara
> <ma...@gmail.com> wrote:
>>
>> Ciao Massimo,
>>
>> I don't think it is something to do with JPA (anyway, have you tried
>> to populate/stub the array with some detached value?)
>> Could you send:
>> 1. the action class source
>> 2. the action definition.
>>
>> Which S2 version are we talking about?
>> Are there any errors in log ?
>>
>>
>> On 31 March 2011 16:26, Massimo Ugues <m....@gmail.com> wrote:
>> > Here the post:
>> >
>> > Hallo all. I have a problem with the struts-json-plugin.
>> >
>> > My action has an association with some JPA entities objects: all of them
>> > are
>> > initialized in the action but when they are serialized via json they all
>> > are
>> > null.
>> >
>> > Here below is the json text that I receive in front of a
>> >
>> > ...
>> > private List<Beneficiario> beneficiari of 5 elements.
>> > private String idBeneficiario = "id";
>> > private User user = new User("mazi");
>> > ...
>> >
>> > {"beneficiari":[null,null,null,null,null],
>> > "idBeneficiario":"id","user":{"name":"Mazi"}}
>> >
>> > All the properties have the right getter. Beneficiario is a JPA entity,
>> > User
>> > not.
>> >
>> > Any ideas?
>> >
>> > Kind regards Massimo
>> >
>> > On Thu, Mar 31, 2011 at 3:57 PM, Dave Newton <da...@gmail.com>
>> > wrote:
>> >
>> >> Perhaps posting the question here would be of value.
>> >>
>> >> Dave
>> >>
>> >> On Thu, Mar 31, 2011 at 9:34 AM, Massimo Ugues <m....@gmail.com>
>> >> wrote:
>> >> > Hallo all.
>> >> > I have a strange issue described here:
>> >> >
>> >>
>> >> http://stackoverflow.com/questions/5497037/struts-json-plugin-problem-serializing-jpa-entity
>> >> >
>> >> > <
>> >>
>> >> http://stackoverflow.com/questions/5497037/struts-json-plugin-problem-serializing-jpa-entity
>> >> >Any
>> >> > idea?
>> >> > Kind regards
>> >> >
>> >> > Massimo
>> >> >
>> >> > --
>> >> > Massimo Ugues
>> >> > http://m4zi.wordpress.com/
>> >> > jabber: m.ugues@gmail.com
>> >> > skype: m.ugues
>> >> >
>> >>
>> >
>> >
>> >
>> > --
>> > Massimo Ugues
>> > http://m4zi.wordpress.com/
>> > jabber: m.ugues@gmail.com
>> > skype: m.ugues
>> >
>>
>>
>>
>> --
>> Maurizio Cucchiara
>
>
>
> --
> Massimo Ugues
> http://m4zi.wordpress.com/
> jabber: m.ugues@gmail.com
> skype: m.ugues
>



-- 
Maurizio Cucchiara

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts2 json plugin problem with jpa entity

Posted by Massimo Ugues <m....@gmail.com>.
Hallo Maurizio.
I tried to create an instance of that class (Beneficiario) in a detached
way, but the problem persist.

The action is created via spring
<bean id="beneficiarioAction" scope="prototype"
class="it.alten.beneficiario.BeneficiarioAction">
 <property name="beneficiarioDao" ref="beneficiarioDaoJpa" />
    </bean>

Could it be a problem?

I think the problem is the Beneficiario class, but to me it seems to be a
Pojo as any other.

Kind regards
Massimo

On Thu, Mar 31, 2011 at 4:50 PM, Maurizio Cucchiara <
maurizio.cucchiara@gmail.com> wrote:

> Ciao Massimo,
>
> I don't think it is something to do with JPA (anyway, have you tried
> to populate/stub the array with some detached value?)
> Could you send:
> 1. the action class source
> 2. the action definition.
>
> Which S2 version are we talking about?
> Are there any errors in log ?
>
>
> On 31 March 2011 16:26, Massimo Ugues <m....@gmail.com> wrote:
> > Here the post:
> >
> > Hallo all. I have a problem with the struts-json-plugin.
> >
> > My action has an association with some JPA entities objects: all of them
> are
> > initialized in the action but when they are serialized via json they all
> are
> > null.
> >
> > Here below is the json text that I receive in front of a
> >
> > ...
> > private List<Beneficiario> beneficiari of 5 elements.
> > private String idBeneficiario = "id";
> > private User user = new User("mazi");
> > ...
> >
> > {"beneficiari":[null,null,null,null,null],
> > "idBeneficiario":"id","user":{"name":"Mazi"}}
> >
> > All the properties have the right getter. Beneficiario is a JPA entity,
> User
> > not.
> >
> > Any ideas?
> >
> > Kind regards Massimo
> >
> > On Thu, Mar 31, 2011 at 3:57 PM, Dave Newton <da...@gmail.com>
> wrote:
> >
> >> Perhaps posting the question here would be of value.
> >>
> >> Dave
> >>
> >> On Thu, Mar 31, 2011 at 9:34 AM, Massimo Ugues <m....@gmail.com>
> wrote:
> >> > Hallo all.
> >> > I have a strange issue described here:
> >> >
> >>
> http://stackoverflow.com/questions/5497037/struts-json-plugin-problem-serializing-jpa-entity
> >> >
> >> > <
> >>
> http://stackoverflow.com/questions/5497037/struts-json-plugin-problem-serializing-jpa-entity
> >> >Any
> >> > idea?
> >> > Kind regards
> >> >
> >> > Massimo
> >> >
> >> > --
> >> > Massimo Ugues
> >> > http://m4zi.wordpress.com/
> >> > jabber: m.ugues@gmail.com
> >> > skype: m.ugues
> >> >
> >>
> >
> >
> >
> > --
> > Massimo Ugues
> > http://m4zi.wordpress.com/
> > jabber: m.ugues@gmail.com
> > skype: m.ugues
> >
>
>
>
> --
> Maurizio Cucchiara
>



-- 
Massimo Ugues
http://m4zi.wordpress.com/
jabber: m.ugues@gmail.com
skype: m.ugues

Re: Struts2 json plugin problem with jpa entity

Posted by Maurizio Cucchiara <ma...@gmail.com>.
Ciao Massimo,

I don't think it is something to do with JPA (anyway, have you tried
to populate/stub the array with some detached value?)
Could you send:
1. the action class source
2. the action definition.

Which S2 version are we talking about?
Are there any errors in log ?


On 31 March 2011 16:26, Massimo Ugues <m....@gmail.com> wrote:
> Here the post:
>
> Hallo all. I have a problem with the struts-json-plugin.
>
> My action has an association with some JPA entities objects: all of them are
> initialized in the action but when they are serialized via json they all are
> null.
>
> Here below is the json text that I receive in front of a
>
> ...
> private List<Beneficiario> beneficiari of 5 elements.
> private String idBeneficiario = "id";
> private User user = new User("mazi");
> ...
>
> {"beneficiari":[null,null,null,null,null],
> "idBeneficiario":"id","user":{"name":"Mazi"}}
>
> All the properties have the right getter. Beneficiario is a JPA entity, User
> not.
>
> Any ideas?
>
> Kind regards Massimo
>
> On Thu, Mar 31, 2011 at 3:57 PM, Dave Newton <da...@gmail.com> wrote:
>
>> Perhaps posting the question here would be of value.
>>
>> Dave
>>
>> On Thu, Mar 31, 2011 at 9:34 AM, Massimo Ugues <m....@gmail.com> wrote:
>> > Hallo all.
>> > I have a strange issue described here:
>> >
>> http://stackoverflow.com/questions/5497037/struts-json-plugin-problem-serializing-jpa-entity
>> >
>> > <
>> http://stackoverflow.com/questions/5497037/struts-json-plugin-problem-serializing-jpa-entity
>> >Any
>> > idea?
>> > Kind regards
>> >
>> > Massimo
>> >
>> > --
>> > Massimo Ugues
>> > http://m4zi.wordpress.com/
>> > jabber: m.ugues@gmail.com
>> > skype: m.ugues
>> >
>>
>
>
>
> --
> Massimo Ugues
> http://m4zi.wordpress.com/
> jabber: m.ugues@gmail.com
> skype: m.ugues
>



-- 
Maurizio Cucchiara

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts2 json plugin problem with jpa entity

Posted by Massimo Ugues <m....@gmail.com>.
Here the post:

Hallo all. I have a problem with the struts-json-plugin.

My action has an association with some JPA entities objects: all of them are
initialized in the action but when they are serialized via json they all are
null.

Here below is the json text that I receive in front of a

...
private List<Beneficiario> beneficiari of 5 elements.
private String idBeneficiario = "id";
private User user = new User("mazi");
...

{"beneficiari":[null,null,null,null,null],
"idBeneficiario":"id","user":{"name":"Mazi"}}

All the properties have the right getter. Beneficiario is a JPA entity, User
not.

Any ideas?

Kind regards Massimo

On Thu, Mar 31, 2011 at 3:57 PM, Dave Newton <da...@gmail.com> wrote:

> Perhaps posting the question here would be of value.
>
> Dave
>
> On Thu, Mar 31, 2011 at 9:34 AM, Massimo Ugues <m....@gmail.com> wrote:
> > Hallo all.
> > I have a strange issue described here:
> >
> http://stackoverflow.com/questions/5497037/struts-json-plugin-problem-serializing-jpa-entity
> >
> > <
> http://stackoverflow.com/questions/5497037/struts-json-plugin-problem-serializing-jpa-entity
> >Any
> > idea?
> > Kind regards
> >
> > Massimo
> >
> > --
> > Massimo Ugues
> > http://m4zi.wordpress.com/
> > jabber: m.ugues@gmail.com
> > skype: m.ugues
> >
>



-- 
Massimo Ugues
http://m4zi.wordpress.com/
jabber: m.ugues@gmail.com
skype: m.ugues

Re: Struts2 json plugin problem with jpa entity

Posted by Dave Newton <da...@gmail.com>.
Perhaps posting the question here would be of value.

Dave

On Thu, Mar 31, 2011 at 9:34 AM, Massimo Ugues <m....@gmail.com> wrote:
> Hallo all.
> I have a strange issue described here:
> http://stackoverflow.com/questions/5497037/struts-json-plugin-problem-serializing-jpa-entity
>
> <http://stackoverflow.com/questions/5497037/struts-json-plugin-problem-serializing-jpa-entity>Any
> idea?
> Kind regards
>
> Massimo
>
> --
> Massimo Ugues
> http://m4zi.wordpress.com/
> jabber: m.ugues@gmail.com
> skype: m.ugues
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org