You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by miro <mi...@yahoo.com> on 2008/11/07 20:27:30 UTC
ajax request and hibernate lazy loading
I am using hibernate and all my collections are lazy , they get loaded only
when called . I am also using ajax to get collection property on click , but
i am getting Lazy loading exception for ajax request where I load the
collection , I am using
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter ,Please
help me how to use OpenSessionInViewFilter with ajax calls ?
--
View this message in context: http://www.nabble.com/ajax-request-and-hibernate-lazy-loading-tp20387124p20387124.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: ajax request and hibernate lazy loading
Posted by Martijn Dashorst <ma...@gmail.com>.
It's a matter of using the right Model: in this case you should use
LoadableDetachableModels—for your list and for the selected item. The
models page on the wiki has ample information, as does this excellent
article by Igor:
http://wicketinaction.com/2008/09/building-a-smart-entitymodel. IIRC
the phonebook also shows you how to achieve this. Assuming you have
"The Book", you might want to check out chapter 4 and read up on
detachable models.
Martijn
On Fri, Nov 7, 2008 at 2:36 PM, miro <mi...@yahoo.com> wrote:
>
> You are right this is not related to ajax and more of hibernate .
> here is my object hirearchy
>
> EaBatchInfo has many EaBatchAuditInfo
>
>
> In the page constructor I load List of EaBatchInfo and render my page
> .By default I pull the first index from list to display EaBatchAuditInfo
> from EaBatchInfo.
> now when user wants to see second EaBatchInfo.EaBatchAuditInfo he
> clicks on second EaBatchInfo in onclick method I try to get
> EaBatchAuditInfo for second EaBatchInfo and here i get lazy loading
> exception becasue the session was closed when rendering my page first time
> and the new session created dosent have list of EaBatchInfo so one
> solution is to have OpenSeissionView pattern in my page construction and
> desctruction , are there any example of open view session pattern for a
> wicket page lifetime ?
>
>
> Martijn Dashorst wrote:
>>
>> I would actually keep using OSIV.
>>
>> To answer the question: probably you are using models wrong. If OSIV
>> works for your normal requests, it works for Ajax requests. There is
>> nothing different between these requests.
>>
>> Martijn
>>
>> On Fri, Nov 7, 2008 at 1:33 PM, Bruno Borges <br...@gmail.com>
>> wrote:
>>> With Ajax request I would probably avoid that pattern.
>>> That could lead to serious problems.
>>>
>>> How about having a different method to load the object with the required
>>> data for that specific ajax request?
>>>
>>> cheers,
>>> Bruno Borges
>>> blog.brunoborges.com.br
>>> +55 21 76727099
>>>
>>> "The glory of great men should always be
>>> measured by the means they have used to
>>> acquire it."
>>> - Francois de La Rochefoucauld
>>>
>>>
>>> On Fri, Nov 7, 2008 at 1:27 PM, miro <mi...@yahoo.com> wrote:
>>>
>>>>
>>>> I am using hibernate and all my collections are lazy , they get loaded
>>>> only
>>>> when called . I am also using ajax to get collection property on click ,
>>>> but
>>>> i am getting Lazy loading exception for ajax request where I load the
>>>> collection , I am using
>>>> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
>>>> ,Please
>>>> help me how to use OpenSessionInViewFilter with ajax calls ?
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/ajax-request-and-hibernate-lazy-loading-tp20387124p20387124.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
>>>>
>>>>
>>>
>>
>>
>>
>> --
>> 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/ajax-request-and-hibernate-lazy-loading-tp20387124p20388432.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
>
>
--
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: ajax request and hibernate lazy loading
Posted by miro <mi...@yahoo.com>.
You are right this is not related to ajax and more of hibernate .
here is my object hirearchy
EaBatchInfo has many EaBatchAuditInfo
In the page constructor I load List of EaBatchInfo and render my page
.By default I pull the first index from list to display EaBatchAuditInfo
from EaBatchInfo.
now when user wants to see second EaBatchInfo.EaBatchAuditInfo he
clicks on second EaBatchInfo in onclick method I try to get
EaBatchAuditInfo for second EaBatchInfo and here i get lazy loading
exception becasue the session was closed when rendering my page first time
and the new session created dosent have list of EaBatchInfo so one
solution is to have OpenSeissionView pattern in my page construction and
desctruction , are there any example of open view session pattern for a
wicket page lifetime ?
Martijn Dashorst wrote:
>
> I would actually keep using OSIV.
>
> To answer the question: probably you are using models wrong. If OSIV
> works for your normal requests, it works for Ajax requests. There is
> nothing different between these requests.
>
> Martijn
>
> On Fri, Nov 7, 2008 at 1:33 PM, Bruno Borges <br...@gmail.com>
> wrote:
>> With Ajax request I would probably avoid that pattern.
>> That could lead to serious problems.
>>
>> How about having a different method to load the object with the required
>> data for that specific ajax request?
>>
>> cheers,
>> Bruno Borges
>> blog.brunoborges.com.br
>> +55 21 76727099
>>
>> "The glory of great men should always be
>> measured by the means they have used to
>> acquire it."
>> - Francois de La Rochefoucauld
>>
>>
>> On Fri, Nov 7, 2008 at 1:27 PM, miro <mi...@yahoo.com> wrote:
>>
>>>
>>> I am using hibernate and all my collections are lazy , they get loaded
>>> only
>>> when called . I am also using ajax to get collection property on click ,
>>> but
>>> i am getting Lazy loading exception for ajax request where I load the
>>> collection , I am using
>>> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
>>> ,Please
>>> help me how to use OpenSessionInViewFilter with ajax calls ?
>>> --
>>> View this message in context:
>>> http://www.nabble.com/ajax-request-and-hibernate-lazy-loading-tp20387124p20387124.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
>>>
>>>
>>
>
>
>
> --
> 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/ajax-request-and-hibernate-lazy-loading-tp20387124p20388432.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: ajax request and hibernate lazy loading
Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
Yep that was also what I were thinking.
Martijn Dashorst wrote:
> I would actually keep using OSIV.
>
> To answer the question: probably you are using models wrong. If OSIV
> works for your normal requests, it works for Ajax requests. There is
> nothing different between these requests.
>
> Martijn
>
> On Fri, Nov 7, 2008 at 1:33 PM, Bruno Borges <br...@gmail.com> wrote:
>
>> With Ajax request I would probably avoid that pattern.
>> That could lead to serious problems.
>>
>> How about having a different method to load the object with the required
>> data for that specific ajax request?
>>
>> cheers,
>> Bruno Borges
>> blog.brunoborges.com.br
>> +55 21 76727099
>>
>> "The glory of great men should always be
>> measured by the means they have used to
>> acquire it."
>> - Francois de La Rochefoucauld
>>
>>
>> On Fri, Nov 7, 2008 at 1:27 PM, miro <mi...@yahoo.com> wrote:
>>
>>
>>> I am using hibernate and all my collections are lazy , they get loaded
>>> only
>>> when called . I am also using ajax to get collection property on click ,
>>> but
>>> i am getting Lazy loading exception for ajax request where I load the
>>> collection , I am using
>>> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter ,Please
>>> help me how to use OpenSessionInViewFilter with ajax calls ?
>>> --
>>> View this message in context:
>>> http://www.nabble.com/ajax-request-and-hibernate-lazy-loading-tp20387124p20387124.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
>>>
>>>
>>>
>
>
>
>
--
-Wicket for love
Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: ajax request and hibernate lazy loading
Posted by Martijn Dashorst <ma...@gmail.com>.
I would actually keep using OSIV.
To answer the question: probably you are using models wrong. If OSIV
works for your normal requests, it works for Ajax requests. There is
nothing different between these requests.
Martijn
On Fri, Nov 7, 2008 at 1:33 PM, Bruno Borges <br...@gmail.com> wrote:
> With Ajax request I would probably avoid that pattern.
> That could lead to serious problems.
>
> How about having a different method to load the object with the required
> data for that specific ajax request?
>
> cheers,
> Bruno Borges
> blog.brunoborges.com.br
> +55 21 76727099
>
> "The glory of great men should always be
> measured by the means they have used to
> acquire it."
> - Francois de La Rochefoucauld
>
>
> On Fri, Nov 7, 2008 at 1:27 PM, miro <mi...@yahoo.com> wrote:
>
>>
>> I am using hibernate and all my collections are lazy , they get loaded
>> only
>> when called . I am also using ajax to get collection property on click ,
>> but
>> i am getting Lazy loading exception for ajax request where I load the
>> collection , I am using
>> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter ,Please
>> help me how to use OpenSessionInViewFilter with ajax calls ?
>> --
>> View this message in context:
>> http://www.nabble.com/ajax-request-and-hibernate-lazy-loading-tp20387124p20387124.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
>>
>>
>
--
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: ajax request and hibernate lazy loading
Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
Should'nt he just use a detachable model?
Bruno Borges wrote:
> With Ajax request I would probably avoid that pattern.
> That could lead to serious problems.
>
> How about having a different method to load the object with the required
> data for that specific ajax request?
>
> cheers,
> Bruno Borges
> blog.brunoborges.com.br
> +55 21 76727099
>
> "The glory of great men should always be
> measured by the means they have used to
> acquire it."
> - Francois de La Rochefoucauld
>
>
> On Fri, Nov 7, 2008 at 1:27 PM, miro <mi...@yahoo.com> wrote:
>
>
>> I am using hibernate and all my collections are lazy , they get loaded
>> only
>> when called . I am also using ajax to get collection property on click ,
>> but
>> i am getting Lazy loading exception for ajax request where I load the
>> collection , I am using
>> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter ,Please
>> help me how to use OpenSessionInViewFilter with ajax calls ?
>> --
>> View this message in context:
>> http://www.nabble.com/ajax-request-and-hibernate-lazy-loading-tp20387124p20387124.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
>>
>>
>>
>
>
--
-Wicket for love
Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: ajax request and hibernate lazy loading
Posted by Bruno Borges <br...@gmail.com>.
With Ajax request I would probably avoid that pattern.
That could lead to serious problems.
How about having a different method to load the object with the required
data for that specific ajax request?
cheers,
Bruno Borges
blog.brunoborges.com.br
+55 21 76727099
"The glory of great men should always be
measured by the means they have used to
acquire it."
- Francois de La Rochefoucauld
On Fri, Nov 7, 2008 at 1:27 PM, miro <mi...@yahoo.com> wrote:
>
> I am using hibernate and all my collections are lazy , they get loaded
> only
> when called . I am also using ajax to get collection property on click ,
> but
> i am getting Lazy loading exception for ajax request where I load the
> collection , I am using
> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter ,Please
> help me how to use OpenSessionInViewFilter with ajax calls ?
> --
> View this message in context:
> http://www.nabble.com/ajax-request-and-hibernate-lazy-loading-tp20387124p20387124.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
>
>