You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Michael Sparer <mi...@gmx.at> on 2008/10/09 16:02:20 UTC

Re: wicket + spring + jpa/ hibernate = lazy load exception

you mean changing each property of an existing object by means of ajax? if
the object is serializable, clone the object and perform the changes on that
object ... if it isn't set the properties in your form and apply them
onsubmit ... or am I missing the point completely?


Lutz Müller wrote:
> 
> It might work if you dont have any ajax on your page. otherwise each ajax
> call 
> happens in a new request and causes your domain object to be retrieved
> from 
> the database.
> this way you lose every change made to your object. writing all changes to 
> database before detaching can be an option, but then you might persist 
> something to your datastore that is in the midst of being edited.
> i would be glad to offer a solution to the problems i just brought up, but
> i 
> am struggling with this problem ever since i started using wicket.
> 
> On Tuesday 30 September 2008 08:40:11 Nino Saturnino Martinez Vazquez Wael 
> wrote:
>> Yup the way that I do it too almost down to every line:)
>>
>> Michael Sparer wrote:
>> > When using the OSIV-filter the lazyload exception may only happen if
>> the
>> > same entity is used among different requests ... sothat it gets
>> detached
>> > from hibernate. have a look at
>> >
>> http://talk-on-tech.blogspot.com/2008/05/custom-reuseable-loadabledetacha
>> >blemode.html ... that's the way we're doing it
>> >
>> > regards,
>> > Michael
>> >
>> > Korbinian Bachl - privat wrote:
>> >>  >I think it could be something about
>> >>  > missing usage of loadabledetachable model..?
>> >>
>> >> not for me, as the original entity is pulled using an
>> >> loadabledetachableModel via a SortedDataProvider :/
>> >>
>> >> if you look around, the all called solution for this is the
>> >> "OpenSessionInViewFilter" and the usage of
>> >> <bean id="transactionManager"
>> >> class="org.springframework.orm.jpa.JpaTransactionManager">
>> >> for that (latter one is used by me, too)
>> >>
>> >> However, the OpenSessionInViewFilter will not work with wicket, even
>> if
>> >> mapped to "/*" in the web.xml
>> >>
>> >> Best,
>> >>
>> >> Korbinian
>> >>
>> >> Nino Saturnino Martinez Vazquez Wael schrieb:
>> >>> Hi Korbinian
>> >>>
>> >>> Im facing the same problems... I also use extended.. So gonna be
>> great
>> >>> to see the outcome of this thread.. I think it could be something
>> about
>> >>> missing usage of loadabledetachable model..?
>> >>>
>> >>> Korbinian Bachl - privat wrote:
>> >>>> Hi,
>> >>>>
>> >>>> I'm currently struggling with the famous "lazy load exception" under
>> >>>> spring + jpa with wicket.
>> >>>>
>> >>>> The problem is, in my case, that i pull an entity from the database
>> >>>> using a spring-bean (@SpringBean) and JPA (hibernate). Then in the
>> >>>> wicket class i need to walk the entity tree a bit, based on the
>> needs
>> >>>> of the user (preloading wont work, as i dont know the direction the
>> >>>> user wants to walk and the whole entity tree is too complex to grab
>> it
>> >>>> all at once).
>> >>>>
>> >>>> If I use the Entity myEntity.getMyOtherConnectedEntity I get the
>> lazy
>> >>>> load exception (transaction already closed). So I tried to use the
>> >>>> OpenSessionInViewFilter to solve this, but it just won't work - no
>> >>>> reason why, as the error stays exactly the same.
>> >>>>
>> >>>> Currently I ended up using this:
>> >>>> @PersistenceContext(type = PersistenceContextType.EXTENDED)
>> >>>> private EntityManager em;
>> >>>>
>> >>>> However, I'm not sure if this is the way it is supposed to be?
>> >>>> ( I read so far that this disables a big part of springs-transaction
>> >>>> handling support but didnt see any impacts so far)
>> >>>>
>> >>>> Has anyone a different aproach/ solution for this using wicket +
>> >>>> spring with JPA?
>> >>>>
>> >>>> Best,
>> >>>>
>> >>>> Korbinan
>> >>>>
>> >>>> PS: im on wicket 1.4-m3
>> >>>>
>> >>>>
>> ---------------------------------------------------------------------
>> >>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>>> For additional commands, e-mail: users-help@wicket.apache.org
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >
>> > -----
>> > Michael Sparer
>> > http://talk-on-tech.blogspot.com
> 
> 
> 


-----
Michael Sparer
http://talk-on-tech.blogspot.com
-- 
View this message in context: http://www.nabble.com/wicket-%2B-spring-%2B-jpa--hibernate-%3D-lazy-load-exception-tp19721199p19899635.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: wicket + spring + jpa/ hibernate = lazy load exception

Posted by Igor Vaynberg <ig...@gmail.com>.
maybe this will help

http://wicketinaction.com/2008/09/building-a-smart-entitymodel/

-igor

On Thu, Oct 9, 2008 at 7:02 AM, Michael Sparer <mi...@gmx.at> wrote:
>
> you mean changing each property of an existing object by means of ajax? if
> the object is serializable, clone the object and perform the changes on that
> object ... if it isn't set the properties in your form and apply them
> onsubmit ... or am I missing the point completely?
>
>
> Lutz Müller wrote:
>>
>> It might work if you dont have any ajax on your page. otherwise each ajax
>> call
>> happens in a new request and causes your domain object to be retrieved
>> from
>> the database.
>> this way you lose every change made to your object. writing all changes to
>> database before detaching can be an option, but then you might persist
>> something to your datastore that is in the midst of being edited.
>> i would be glad to offer a solution to the problems i just brought up, but
>> i
>> am struggling with this problem ever since i started using wicket.
>>
>> On Tuesday 30 September 2008 08:40:11 Nino Saturnino Martinez Vazquez Wael
>> wrote:
>>> Yup the way that I do it too almost down to every line:)
>>>
>>> Michael Sparer wrote:
>>> > When using the OSIV-filter the lazyload exception may only happen if
>>> the
>>> > same entity is used among different requests ... sothat it gets
>>> detached
>>> > from hibernate. have a look at
>>> >
>>> http://talk-on-tech.blogspot.com/2008/05/custom-reuseable-loadabledetacha
>>> >blemode.html ... that's the way we're doing it
>>> >
>>> > regards,
>>> > Michael
>>> >
>>> > Korbinian Bachl - privat wrote:
>>> >>  >I think it could be something about
>>> >>  > missing usage of loadabledetachable model..?
>>> >>
>>> >> not for me, as the original entity is pulled using an
>>> >> loadabledetachableModel via a SortedDataProvider :/
>>> >>
>>> >> if you look around, the all called solution for this is the
>>> >> "OpenSessionInViewFilter" and the usage of
>>> >> <bean id="transactionManager"
>>> >> class="org.springframework.orm.jpa.JpaTransactionManager">
>>> >> for that (latter one is used by me, too)
>>> >>
>>> >> However, the OpenSessionInViewFilter will not work with wicket, even
>>> if
>>> >> mapped to "/*" in the web.xml
>>> >>
>>> >> Best,
>>> >>
>>> >> Korbinian
>>> >>
>>> >> Nino Saturnino Martinez Vazquez Wael schrieb:
>>> >>> Hi Korbinian
>>> >>>
>>> >>> Im facing the same problems... I also use extended.. So gonna be
>>> great
>>> >>> to see the outcome of this thread.. I think it could be something
>>> about
>>> >>> missing usage of loadabledetachable model..?
>>> >>>
>>> >>> Korbinian Bachl - privat wrote:
>>> >>>> Hi,
>>> >>>>
>>> >>>> I'm currently struggling with the famous "lazy load exception" under
>>> >>>> spring + jpa with wicket.
>>> >>>>
>>> >>>> The problem is, in my case, that i pull an entity from the database
>>> >>>> using a spring-bean (@SpringBean) and JPA (hibernate). Then in the
>>> >>>> wicket class i need to walk the entity tree a bit, based on the
>>> needs
>>> >>>> of the user (preloading wont work, as i dont know the direction the
>>> >>>> user wants to walk and the whole entity tree is too complex to grab
>>> it
>>> >>>> all at once).
>>> >>>>
>>> >>>> If I use the Entity myEntity.getMyOtherConnectedEntity I get the
>>> lazy
>>> >>>> load exception (transaction already closed). So I tried to use the
>>> >>>> OpenSessionInViewFilter to solve this, but it just won't work - no
>>> >>>> reason why, as the error stays exactly the same.
>>> >>>>
>>> >>>> Currently I ended up using this:
>>> >>>> @PersistenceContext(type = PersistenceContextType.EXTENDED)
>>> >>>> private EntityManager em;
>>> >>>>
>>> >>>> However, I'm not sure if this is the way it is supposed to be?
>>> >>>> ( I read so far that this disables a big part of springs-transaction
>>> >>>> handling support but didnt see any impacts so far)
>>> >>>>
>>> >>>> Has anyone a different aproach/ solution for this using wicket +
>>> >>>> spring with JPA?
>>> >>>>
>>> >>>> Best,
>>> >>>>
>>> >>>> Korbinan
>>> >>>>
>>> >>>> PS: im on wicket 1.4-m3
>>> >>>>
>>> >>>>
>>> ---------------------------------------------------------------------
>>> >>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> >>>> For additional commands, e-mail: users-help@wicket.apache.org
>>> >>
>>> >> ---------------------------------------------------------------------
>>> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> >> For additional commands, e-mail: users-help@wicket.apache.org
>>> >
>>> > -----
>>> > Michael Sparer
>>> > http://talk-on-tech.blogspot.com
>>
>>
>>
>
>
> -----
> Michael Sparer
> http://talk-on-tech.blogspot.com
> --
> View this message in context: http://www.nabble.com/wicket-%2B-spring-%2B-jpa--hibernate-%3D-lazy-load-exception-tp19721199p19899635.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
>
>

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