You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Bálint Kriván <ba...@krivan.hu> on 2012/03/18 13:36:57 UTC

Wicket + JPA lazy-loading

Hey!

It seems that when wicket is trying to serialize the persistent objects
(probably to session) the lazy loading kicks in and it retrieves the whole
graph.
Not sure if wicket is using the default java serialization or a special
one, but is there anybody else who is/were experiencing the same? By any
chance would you have any suggestion how can I overcome this?
It would be a great solution if an association is persisted when it's
loaded, but if it isn't then do not lazy load it, just leave it null.

Thanks!

Regards,
Bálint Kriván

Re: Wicket + JPA lazy-loading

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

2012/3/18 Bálint Kriván <ba...@krivan.hu>:
> I don't want to serialize them but wicket does (I have a list of objects
> which I pass to a ListView).
> IIRC, If I use LDM I can make wicket to serialize only an ID and when it is
> readed back I can reach the backend to get the correct object for that ID.
> If I would switch to this probably it would be more query than now, because
> even the parent objects should be retrieved from the DB one-by-one.
> It would be enough for me if I could make wicket not to try to serialize
> these objects (these are retrieved in the constructor so I don't see the
> need to save them on the first place)

Wicket serializes the page and all inside it. If you keep refs to
these objects from your page then Java Serialization will try to
serialize them.
You can keep a set of all ids and load them (via LDM) with just one
SQL query at any time they are needed.

>
> On Sun, Mar 18, 2012 at 1:56 PM, James Carman <ja...@carmanconsulting.com>wrote:
>
>> Use a LoadableDetachableModel.  You shouldn't be serializing
>> persistent objects (unless of course you're in the middle of editing
>> them or something).
>>
>> On Sun, Mar 18, 2012 at 8:36 AM, Bálint Kriván <ba...@krivan.hu> wrote:
>> > Hey!
>> >
>> > It seems that when wicket is trying to serialize the persistent objects
>> > (probably to session) the lazy loading kicks in and it retrieves the
>> whole
>> > graph.
>> > Not sure if wicket is using the default java serialization or a special
>> > one, but is there anybody else who is/were experiencing the same? By any
>> > chance would you have any suggestion how can I overcome this?
>> > It would be a great solution if an association is persisted when it's
>> > loaded, but if it isn't then do not lazy load it, just leave it null.
>> >
>> > Thanks!
>> >
>> > Regards,
>> > Bálint Kriván
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
> --
> Üdv,
> Kriván Bálint



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket + JPA lazy-loading

Posted by James Carman <jc...@carmanconsulting.com>.
Try with an ldm I'd say.
On Mar 18, 2012 9:04 AM, "Bálint Kriván" <ba...@krivan.hu> wrote:

> I don't want to serialize them but wicket does (I have a list of objects
> which I pass to a ListView).
> IIRC, If I use LDM I can make wicket to serialize only an ID and when it is
> readed back I can reach the backend to get the correct object for that ID.
> If I would switch to this probably it would be more query than now, because
> even the parent objects should be retrieved from the DB one-by-one.
> It would be enough for me if I could make wicket not to try to serialize
> these objects (these are retrieved in the constructor so I don't see the
> need to save them on the first place)
>
> On Sun, Mar 18, 2012 at 1:56 PM, James Carman <james@carmanconsulting.com
> >wrote:
>
> > Use a LoadableDetachableModel.  You shouldn't be serializing
> > persistent objects (unless of course you're in the middle of editing
> > them or something).
> >
> > On Sun, Mar 18, 2012 at 8:36 AM, Bálint Kriván <ba...@krivan.hu> wrote:
> > > Hey!
> > >
> > > It seems that when wicket is trying to serialize the persistent objects
> > > (probably to session) the lazy loading kicks in and it retrieves the
> > whole
> > > graph.
> > > Not sure if wicket is using the default java serialization or a special
> > > one, but is there anybody else who is/were experiencing the same? By
> any
> > > chance would you have any suggestion how can I overcome this?
> > > It would be a great solution if an association is persisted when it's
> > > loaded, but if it isn't then do not lazy load it, just leave it null.
> > >
> > > Thanks!
> > >
> > > Regards,
> > > Bálint Kriván
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
>
> --
> Üdv,
> Kriván Bálint
>

Re: Wicket + JPA lazy-loading

Posted by Bálint Kriván <ba...@krivan.hu>.
I don't want to serialize them but wicket does (I have a list of objects
which I pass to a ListView).
IIRC, If I use LDM I can make wicket to serialize only an ID and when it is
readed back I can reach the backend to get the correct object for that ID.
If I would switch to this probably it would be more query than now, because
even the parent objects should be retrieved from the DB one-by-one.
It would be enough for me if I could make wicket not to try to serialize
these objects (these are retrieved in the constructor so I don't see the
need to save them on the first place)

On Sun, Mar 18, 2012 at 1:56 PM, James Carman <ja...@carmanconsulting.com>wrote:

> Use a LoadableDetachableModel.  You shouldn't be serializing
> persistent objects (unless of course you're in the middle of editing
> them or something).
>
> On Sun, Mar 18, 2012 at 8:36 AM, Bálint Kriván <ba...@krivan.hu> wrote:
> > Hey!
> >
> > It seems that when wicket is trying to serialize the persistent objects
> > (probably to session) the lazy loading kicks in and it retrieves the
> whole
> > graph.
> > Not sure if wicket is using the default java serialization or a special
> > one, but is there anybody else who is/were experiencing the same? By any
> > chance would you have any suggestion how can I overcome this?
> > It would be a great solution if an association is persisted when it's
> > loaded, but if it isn't then do not lazy load it, just leave it null.
> >
> > Thanks!
> >
> > Regards,
> > Bálint Kriván
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Üdv,
Kriván Bálint

Re: Wicket + JPA lazy-loading

Posted by James Carman <ja...@carmanconsulting.com>.
Use a LoadableDetachableModel.  You shouldn't be serializing
persistent objects (unless of course you're in the middle of editing
them or something).

On Sun, Mar 18, 2012 at 8:36 AM, Bálint Kriván <ba...@krivan.hu> wrote:
> Hey!
>
> It seems that when wicket is trying to serialize the persistent objects
> (probably to session) the lazy loading kicks in and it retrieves the whole
> graph.
> Not sure if wicket is using the default java serialization or a special
> one, but is there anybody else who is/were experiencing the same? By any
> chance would you have any suggestion how can I overcome this?
> It would be a great solution if an association is persisted when it's
> loaded, but if it isn't then do not lazy load it, just leave it null.
>
> Thanks!
>
> Regards,
> Bálint Kriván

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org