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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]>
>>> 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: [EMAIL PROTECTED]
>>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
> --
> Erik van Oosten
> http://www.day-to-day-stuff.blogspot.com/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-- 
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to