You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Graeme Knight <gr...@gmail.com> on 2008/11/11 15:03:03 UTC

IDataProvider Implementation.

Hi.

>From the examples I've seen the IDataProvider implementation of the iterator
method brings back (for example) a list of keys from the database.

The model method uses something like a LoadableDetachableModel to populate a
model for use by the consumer using the list of keys previously retrieved.

This seems like a lot of database hits to me. Is this simply because of the
serialization/model mechanism?

It seems to me that the iterator could/should bring back the data in one hit
and then after use be detached. Is this common?

Many thanks, Graeme.
-- 
View this message in context: http://www.nabble.com/IDataProvider-Implementation.-tp20440141p20440141.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: IDataProvider Implementation.

Posted by Graeme Knight <gr...@gmail.com>.
Hi guys,

I am using hibernate and it is caching (which is great) so that overhead is
not a problem -

after some reflection I think it appears to me that because you get rid of
the loadabledetachablemodel to 'save database hits' (which if cached,
doesn't really) then the affect is more serialized data. Bad.

Got it.

Thanks, Graeme.
 

Martijn Dashorst wrote:
> 
> That, and that typically your ORM (hibernate, etc) will put the object
> in second level cache. The LDM should hit that cache most of the time
> between requests.
> 
> Martijn
> 
> On Tue, Nov 11, 2008 at 3:58 PM, Erik van Oosten <e....@grons.nl>
> wrote:
>> Not a good idea for large objects. A few days back I improved load time
>> of a
>> page from more then 40 sec to about 5 sec by replacing "new
>> Model(object)"
>> with a proper LoadableDetachableModel.
>>
>> Nevertheless, there is no reason to let the LoadableDetachableModel get
>> the
>> object if you already have it, just pass the object to the constructor!
>>
>> E.g. see first ctor below.
>>
>> public class LoadableMemberModel
>>       extends LoadableDetachableModel<Member> {
>>
>>   @SpringBean
>>   private MemberService memberService;
>>
>>   private long memberId;
>>
>>   //
>>   // Constructor that has object has direct parameter
>>   //
>>   public LoadableMemberModel(Member member) {
>>       super(member);
>>       this.memberId = member.getId();
>>   }
>> *
>> *    public LoadableMemberModel(long memberId) {
>>       this.memberId = memberId;
>>   }
>>
>>   protected Member load() {
>>       InjectorHolder.getInjector().inject(this);
>>       return memberService.getById(memberId);
>>   }
>> }
>>
>>
>>
>> Regards,
>>   Erik.
>>
>>
>> Graeme Knight wrote:
>>>
>>> Hey Jeremy,
>>>
>>> Thanks for the heads up - actually that's what I ended up doing this
>>> morning. Works like a charm!
>>>
>>> Cheers, Graeme.
>>>
>>>
>>> Jeremy Thomerson-5 wrote:
>>>
>>>>
>>>> In my apps, I bring them all in whenever the first call to iterator or
>>>> size
>>>> is done, and cache them until detach.  It's a very reasonable pattern.
>>>> Then
>>>> in the model method, I basically do new Model(object)....
>>>>
>>>>
>>>> --
>>>> Jeremy Thomerson
>>>> http://www.wickettraining.com
>>>>
>>>>
>>>> On Tue, Nov 11, 2008 at 8:03 AM, Graeme Knight <gr...@gmail.com>
>>>> wrote:
>>>>
>>>>
>>>>>
>>>>> Hi.
>>>>>
>>>>> From the examples I've seen the IDataProvider implementation of the
>>>>> iterator
>>>>> method brings back (for example) a list of keys from the database.
>>>>>
>>>>> The model method uses something like a LoadableDetachableModel to
>>>>> populate
>>>>> a
>>>>> model for use by the consumer using the list of keys previously
>>>>> retrieved.
>>>>>
>>>>> This seems like a lot of database hits to me. Is this simply because
>>>>> of
>>>>> the
>>>>> serialization/model mechanism?
>>>>>
>>>>> It seems to me that the iterator could/should bring back the data in
>>>>> one
>>>>> hit
>>>>> and then after use be detached. Is this common?
>>>>>
>>>>> Many thanks, Graeme.
>>>>> --
>>>>> View this message in context:
>>>>>
>>>>> http://www.nabble.com/IDataProvider-Implementation.-tp20440141p20440141.html
>>>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>> --
>> Erik van Oosten
>> http://www.day-to-day-stuff.blogspot.com/
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> 
> 
> -- 
> Become a Wicket expert, learn from the best: http://wicketinaction.com
> Apache Wicket 1.3.4 is released
> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/IDataProvider-Implementation.-tp20440141p20441836.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: IDataProvider Implementation.

Posted by Martijn Dashorst <ma...@gmail.com>.
That, and that typically your ORM (hibernate, etc) will put the object
in second level cache. The LDM should hit that cache most of the time
between requests.

Martijn

On Tue, Nov 11, 2008 at 3:58 PM, Erik van Oosten <e....@grons.nl> wrote:
> Not a good idea for large objects. A few days back I improved load time of a
> page from more then 40 sec to about 5 sec by replacing "new Model(object)"
> with a proper LoadableDetachableModel.
>
> Nevertheless, there is no reason to let the LoadableDetachableModel get the
> object if you already have it, just pass the object to the constructor!
>
> E.g. see first ctor below.
>
> public class LoadableMemberModel
>       extends LoadableDetachableModel<Member> {
>
>   @SpringBean
>   private MemberService memberService;
>
>   private long memberId;
>
>   //
>   // Constructor that has object has direct parameter
>   //
>   public LoadableMemberModel(Member member) {
>       super(member);
>       this.memberId = member.getId();
>   }
> *
> *    public LoadableMemberModel(long memberId) {
>       this.memberId = memberId;
>   }
>
>   protected Member load() {
>       InjectorHolder.getInjector().inject(this);
>       return memberService.getById(memberId);
>   }
> }
>
>
>
> Regards,
>   Erik.
>
>
> Graeme Knight wrote:
>>
>> Hey Jeremy,
>>
>> Thanks for the heads up - actually that's what I ended up doing this
>> morning. Works like a charm!
>>
>> Cheers, Graeme.
>>
>>
>> Jeremy Thomerson-5 wrote:
>>
>>>
>>> In my apps, I bring them all in whenever the first call to iterator or
>>> size
>>> is done, and cache them until detach.  It's a very reasonable pattern.
>>> Then
>>> in the model method, I basically do new Model(object)....
>>>
>>>
>>> --
>>> Jeremy Thomerson
>>> http://www.wickettraining.com
>>>
>>>
>>> On Tue, Nov 11, 2008 at 8:03 AM, Graeme Knight <gr...@gmail.com>
>>> wrote:
>>>
>>>
>>>>
>>>> Hi.
>>>>
>>>> From the examples I've seen the IDataProvider implementation of the
>>>> iterator
>>>> method brings back (for example) a list of keys from the database.
>>>>
>>>> The model method uses something like a LoadableDetachableModel to
>>>> populate
>>>> a
>>>> model for use by the consumer using the list of keys previously
>>>> retrieved.
>>>>
>>>> This seems like a lot of database hits to me. Is this simply because of
>>>> the
>>>> serialization/model mechanism?
>>>>
>>>> It seems to me that the iterator could/should bring back the data in one
>>>> hit
>>>> and then after use be detached. Is this common?
>>>>
>>>> Many thanks, Graeme.
>>>> --
>>>> View this message in context:
>>>>
>>>> http://www.nabble.com/IDataProvider-Implementation.-tp20440141p20440141.html
>>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
> --
> Erik van Oosten
> http://www.day-to-day-stuff.blogspot.com/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.4 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

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


Re: IDataProvider Implementation.

Posted by Erik van Oosten <e....@grons.nl>.
Not a good idea for large objects. A few days back I improved load time 
of a page from more then 40 sec to about 5 sec by replacing "new 
Model(object)" with a proper LoadableDetachableModel.

Nevertheless, there is no reason to let the LoadableDetachableModel get 
the object if you already have it, just pass the object to the constructor!

E.g. see first ctor below.

public class LoadableMemberModel
        extends LoadableDetachableModel<Member> {

    @SpringBean
    private MemberService memberService;

    private long memberId;

    //
    // Constructor that has object has direct parameter
    //
    public LoadableMemberModel(Member member) {
        super(member);
        this.memberId = member.getId();
    }
*
*    public LoadableMemberModel(long memberId) {
        this.memberId = memberId;
    }

    protected Member load() {
        InjectorHolder.getInjector().inject(this);
        return memberService.getById(memberId);
    }
}



Regards,
    Erik.


Graeme Knight wrote:
> Hey Jeremy,
>
> Thanks for the heads up - actually that's what I ended up doing this
> morning. Works like a charm!
>
> Cheers, Graeme.
>
>
> Jeremy Thomerson-5 wrote:
>   
>> In my apps, I bring them all in whenever the first call to iterator or
>> size
>> is done, and cache them until detach.  It's a very reasonable pattern. 
>> Then
>> in the model method, I basically do new Model(object)....
>>
>>
>> -- 
>> Jeremy Thomerson
>> http://www.wickettraining.com
>>
>>
>> On Tue, Nov 11, 2008 at 8:03 AM, Graeme Knight <gr...@gmail.com>
>> wrote:
>>
>>     
>>> Hi.
>>>
>>> From the examples I've seen the IDataProvider implementation of the
>>> iterator
>>> method brings back (for example) a list of keys from the database.
>>>
>>> The model method uses something like a LoadableDetachableModel to
>>> populate
>>> a
>>> model for use by the consumer using the list of keys previously
>>> retrieved.
>>>
>>> This seems like a lot of database hits to me. Is this simply because of
>>> the
>>> serialization/model mechanism?
>>>
>>> It seems to me that the iterator could/should bring back the data in one
>>> hit
>>> and then after use be detached. Is this common?
>>>
>>> Many thanks, Graeme.
>>> --
>>> View this message in context:
>>> http://www.nabble.com/IDataProvider-Implementation.-tp20440141p20440141.html
>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>       
>>     
>
>   


-- 
Erik van Oosten
http://www.day-to-day-stuff.blogspot.com/


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


Re: IDataProvider Implementation.

Posted by Graeme Knight <gr...@gmail.com>.
Hey Jeremy,

Thanks for the heads up - actually that's what I ended up doing this
morning. Works like a charm!

Cheers, Graeme.


Jeremy Thomerson-5 wrote:
> 
> In my apps, I bring them all in whenever the first call to iterator or
> size
> is done, and cache them until detach.  It's a very reasonable pattern. 
> Then
> in the model method, I basically do new Model(object)....
> 
> 
> -- 
> Jeremy Thomerson
> http://www.wickettraining.com
> 
> 
> On Tue, Nov 11, 2008 at 8:03 AM, Graeme Knight <gr...@gmail.com>
> wrote:
> 
>>
>> Hi.
>>
>> From the examples I've seen the IDataProvider implementation of the
>> iterator
>> method brings back (for example) a list of keys from the database.
>>
>> The model method uses something like a LoadableDetachableModel to
>> populate
>> a
>> model for use by the consumer using the list of keys previously
>> retrieved.
>>
>> This seems like a lot of database hits to me. Is this simply because of
>> the
>> serialization/model mechanism?
>>
>> It seems to me that the iterator could/should bring back the data in one
>> hit
>> and then after use be detached. Is this common?
>>
>> Many thanks, Graeme.
>> --
>> View this message in context:
>> http://www.nabble.com/IDataProvider-Implementation.-tp20440141p20440141.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/IDataProvider-Implementation.-tp20440141p20441038.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: IDataProvider Implementation.

Posted by Jeremy Thomerson <je...@wickettraining.com>.
In my apps, I bring them all in whenever the first call to iterator or size
is done, and cache them until detach.  It's a very reasonable pattern.  Then
in the model method, I basically do new Model(object)....


-- 
Jeremy Thomerson
http://www.wickettraining.com


On Tue, Nov 11, 2008 at 8:03 AM, Graeme Knight <gr...@gmail.com> wrote:

>
> Hi.
>
> From the examples I've seen the IDataProvider implementation of the
> iterator
> method brings back (for example) a list of keys from the database.
>
> The model method uses something like a LoadableDetachableModel to populate
> a
> model for use by the consumer using the list of keys previously retrieved.
>
> This seems like a lot of database hits to me. Is this simply because of the
> serialization/model mechanism?
>
> It seems to me that the iterator could/should bring back the data in one
> hit
> and then after use be detached. Is this common?
>
> Many thanks, Graeme.
> --
> View this message in context:
> http://www.nabble.com/IDataProvider-Implementation.-tp20440141p20440141.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>