You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Anton Komratov <a....@gmail.com> on 2009/09/17 15:19:54 UTC
Handling Hibernate session (LazyInitializationException)
Hi, I'm using Wicket + Hibernate (without Spring).
In my application I open Hibernate *session* in WebRequestCycle.*
onBeginRequest*() and close it in WebRequestCycle.*onEndRequest*().
But having association (many-to-one mappings between classes) I've got
LazyInitializationException (no Session). I've just set parameter
"*lazy*"=false
in hibernate mapping file to "many-to-one" mappings. And it worked fine -
amount of data stored in memory in this case was not critical.
Since the system is growing furhter, the method with no lazy initialization
is no more suitable. Could you, please, advise me a way to handle hibernate
session to have lazy initialization. (Solution with no Spring is
preferable).
// Best regards, Anton
Re: Handling Hibernate session (LazyInitializationException)
Posted by Peter Ertl <pe...@gmx.org>.
yes - it run's smoothly together ...
Am 18.09.2009 um 07:44 schrieb Michael Mosmann:
> Am Freitag, den 18.09.2009, 00:35 +0200 schrieb Peter Ertl:
>> as an further improvement use salve to completely remove your
>> headache :-)
>>
>> http://code.google.com/p/salve
>
> thank you.. interesting stuff..
> do you have any experience in combination with hibernate?
>
> mm:)
>
>> Am 17.09.2009 um 23:51 schrieb Michael Mosmann:
>>
>>> Hi,
>>>
>>>> (Solution with no Spring is
>>>> preferable).
>>>
>>> Use Spring, because it will limit your headache..
>>>
>>> Maybe this is usefull:
>>> http://www.wicket-praxis.de/blog/download/
>>>
>>> use Link behind "Praxisbuch Wicket Beispielcode" for a maven-based
>>> project with:
>>> - Spring (open session in view filter, @SpringBean-Annotation
>>> support,
>>> Hibernate UnitTest)
>>> - Hibernate (Hibernate Annotation Support)
>>>
>>> mm:)
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>
>
> ---------------------------------------------------------------------
> 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
Re: Handling Hibernate session (LazyInitializationException)
Posted by Michael Mosmann <mi...@mosmann.de>.
Am Freitag, den 18.09.2009, 00:35 +0200 schrieb Peter Ertl:
> as an further improvement use salve to completely remove your
> headache :-)
>
> http://code.google.com/p/salve
thank you.. interesting stuff..
do you have any experience in combination with hibernate?
mm:)
> Am 17.09.2009 um 23:51 schrieb Michael Mosmann:
>
> > Hi,
> >
> >> (Solution with no Spring is
> >> preferable).
> >
> > Use Spring, because it will limit your headache..
> >
> > Maybe this is usefull:
> > http://www.wicket-praxis.de/blog/download/
> >
> > use Link behind "Praxisbuch Wicket Beispielcode" for a maven-based
> > project with:
> > - Spring (open session in view filter, @SpringBean-Annotation support,
> > Hibernate UnitTest)
> > - Hibernate (Hibernate Annotation Support)
> >
> > mm:)
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Handling Hibernate session (LazyInitializationException)
Posted by Peter Ertl <pe...@gmx.org>.
as an further improvement use salve to completely remove your
headache :-)
http://code.google.com/p/salve
Am 17.09.2009 um 23:51 schrieb Michael Mosmann:
> Hi,
>
>> (Solution with no Spring is
>> preferable).
>
> Use Spring, because it will limit your headache..
>
> Maybe this is usefull:
> http://www.wicket-praxis.de/blog/download/
>
> use Link behind "Praxisbuch Wicket Beispielcode" for a maven-based
> project with:
> - Spring (open session in view filter, @SpringBean-Annotation support,
> Hibernate UnitTest)
> - Hibernate (Hibernate Annotation Support)
>
> mm:)
>
>
>
> ---------------------------------------------------------------------
> 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
Re: Handling Hibernate session (LazyInitializationException)
Posted by Michael Mosmann <mi...@mosmann.de>.
Hi,
> (Solution with no Spring is
> preferable).
Use Spring, because it will limit your headache..
Maybe this is usefull:
http://www.wicket-praxis.de/blog/download/
use Link behind "Praxisbuch Wicket Beispielcode" for a maven-based
project with:
- Spring (open session in view filter, @SpringBean-Annotation support,
Hibernate UnitTest)
- Hibernate (Hibernate Annotation Support)
mm:)
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Handling Hibernate session (LazyInitializationException)
Posted by Matthias Keller <ma...@ergon.ch>.
Hi Anton
The Problem you encounter is probably because you're holding on to a
hibernate object between requests, thus the references are not valid
anymore.
Have a look at
http://wicketinaction.com/2008/09/building-a-smart-entitymodel/
This works for us with hibernate.
Matt
Anton Komratov wrote:
> Hi, I'm using Wicket + Hibernate (without Spring).
> In my application I open Hibernate *session* in WebRequestCycle.*
> onBeginRequest*() and close it in WebRequestCycle.*onEndRequest*().
>
> But having association (many-to-one mappings between classes) I've got
> LazyInitializationException (no Session). I've just set parameter
> "*lazy*"=false
> in hibernate mapping file to "many-to-one" mappings. And it worked fine -
> amount of data stored in memory in this case was not critical.
>
> Since the system is growing furhter, the method with no lazy initialization
> is no more suitable. Could you, please, advise me a way to handle hibernate
> session to have lazy initialization. (Solution with no Spring is
> preferable).
>
> // Best regards, Anton
>
>
Re: Handling Hibernate session (LazyInitializationException)
Posted by Martin Sachs <sa...@gmail.com>.
hi,
you could also use an Aspekt (e.g. with Aspekj) zu reinit all lazy
proxies on the next request. The Proxy objects would be detachted and
serialized throw
the models. With an Aspekt you can re-attach ALL hibernate proxies,
without triggering the DB.
Martin
Anton Komratov schrieb:
> Hi, I'm using Wicket + Hibernate (without Spring).
> In my application I open Hibernate *session* in WebRequestCycle.*
> onBeginRequest*() and close it in WebRequestCycle.*onEndRequest*().
>
> But having association (many-to-one mappings between classes) I've got
> LazyInitializationException (no Session). I've just set parameter
> "*lazy*"=false
> in hibernate mapping file to "many-to-one" mappings. And it worked fine -
> amount of data stored in memory in this case was not critical.
>
> Since the system is growing furhter, the method with no lazy initialization
> is no more suitable. Could you, please, advise me a way to handle hibernate
> session to have lazy initialization. (Solution with no Spring is
> preferable).
>
> // Best regards, Anton
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org