You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Jeffrey Schneller <je...@envisa.com> on 2009/10/07 17:56:11 UTC
Storing entity object in session - how to do it?
Looking through the archives I saw some posts that said you should not
store entity objects [for example object coming from hibernate] in the
session. This makes sense to me as I just hit the problem.
The archives gave lots of advice but everything seemed to contradict and
no one posted a working solution.
Current architecture:
My wicket application is implementing Guice and Warp-Persist.
I have a MySession object which extends WebSession.
Inside MySession I wanted to store the entity object called Account
[which has a bunch of lazy load properties from hibernate]. Obviously
this isn't going to work.
I have a MyUnauthorizedListener which implements
IUnauthorizedComponentInstatiationListener so that I can send the user
to a 'change password' page based on properties in their Account [flag
for changing password or a time limit since last password change] or to
a 'login' page if the password doesn't need to be changed.
I also have a MyUserRolesAuthorizer which implements
IRoleCheckingStrategy so that I can see if the account has the proper
roles to view certain pages.
Solution Tried:
I thought of just storing the id of the account in the session. Then
when I need the actual Account object I can just pull it from the db.
This works fine on Pages but I can't inject the DAO into
MyUnauthorizedListener and MyUserRolesAuthorizer since Guice only
injects into components [correct?]
Do I need to pass the Dao to MyUnauthorizedListener and
MyUserRolesAuthorizer via the WebApplication [assuming this is a
component]?
Any ideas? Solutions? Or have I architected this incorrectly?
Thanks.
Re: Storing entity object in session - how to do it?
Posted by Marcelo Fukushima <ta...@gmail.com>.
btw, im not actually suggesting you do that because keeping the key
pieces in memory must be a lot faster than pulling from the DB for
every component
On Wed, Oct 7, 2009 at 7:34 PM, Marcelo Fukushima <ta...@gmail.com> wrote:
> cant you inject the DAO's to the listeners in the moment you create
> and attack the listeners to your application?
> If you have the Injector at that moment, you could even pull your
> listeners from the Injector, no?
>
> On Wed, Oct 7, 2009 at 5:21 PM, Jeffrey Schneller
> <je...@envisa.com> wrote:
>> Thanks. I took your suggestion and now just store the key pieces that I need in the session and it looks like it is working.
>>
>> -----Original Message-----
>> From: Martin Makundi [mailto:martin.makundi@koodaripalvelut.com]
>> Sent: Wednesday, October 07, 2009 1:05 PM
>> To: users@wicket.apache.org
>> Subject: Re: Storing entity object in session - how to do it?
>>
>> We have (some key) entities (successfully) in Session. But they are
>> not lazy-load entities so they act like plain-old-java-beans.
>>
>> **
>> Martin
>>
>> 2009/10/7 Jeffrey Schneller <je...@envisa.com>:
>>> Looking through the archives I saw some posts that said you should not
>>> store entity objects [for example object coming from hibernate] in the
>>> session. This makes sense to me as I just hit the problem.
>>>
>>> The archives gave lots of advice but everything seemed to contradict and
>>> no one posted a working solution.
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> 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
>>
>>
>
>
>
> --
> http://mapsdev.blogspot.com/
> Marcelo Takeshi Fukushima
>
--
http://mapsdev.blogspot.com/
Marcelo Takeshi Fukushima
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Storing entity object in session - how to do it?
Posted by Marcelo Fukushima <ta...@gmail.com>.
cant you inject the DAO's to the listeners in the moment you create
and attack the listeners to your application?
If you have the Injector at that moment, you could even pull your
listeners from the Injector, no?
On Wed, Oct 7, 2009 at 5:21 PM, Jeffrey Schneller
<je...@envisa.com> wrote:
> Thanks. I took your suggestion and now just store the key pieces that I need in the session and it looks like it is working.
>
> -----Original Message-----
> From: Martin Makundi [mailto:martin.makundi@koodaripalvelut.com]
> Sent: Wednesday, October 07, 2009 1:05 PM
> To: users@wicket.apache.org
> Subject: Re: Storing entity object in session - how to do it?
>
> We have (some key) entities (successfully) in Session. But they are
> not lazy-load entities so they act like plain-old-java-beans.
>
> **
> Martin
>
> 2009/10/7 Jeffrey Schneller <je...@envisa.com>:
>> Looking through the archives I saw some posts that said you should not
>> store entity objects [for example object coming from hibernate] in the
>> session. This makes sense to me as I just hit the problem.
>>
>> The archives gave lots of advice but everything seemed to contradict and
>> no one posted a working solution.
>>
>>
>
> ---------------------------------------------------------------------
> 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
>
>
--
http://mapsdev.blogspot.com/
Marcelo Takeshi Fukushima
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
RE: Storing entity object in session - how to do it?
Posted by Jeffrey Schneller <je...@envisa.com>.
Thanks. I took your suggestion and now just store the key pieces that I need in the session and it looks like it is working.
-----Original Message-----
From: Martin Makundi [mailto:martin.makundi@koodaripalvelut.com]
Sent: Wednesday, October 07, 2009 1:05 PM
To: users@wicket.apache.org
Subject: Re: Storing entity object in session - how to do it?
We have (some key) entities (successfully) in Session. But they are
not lazy-load entities so they act like plain-old-java-beans.
**
Martin
2009/10/7 Jeffrey Schneller <je...@envisa.com>:
> Looking through the archives I saw some posts that said you should not
> store entity objects [for example object coming from hibernate] in the
> session. This makes sense to me as I just hit the problem.
>
> The archives gave lots of advice but everything seemed to contradict and
> no one posted a working solution.
>
>
---------------------------------------------------------------------
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: Storing entity object in session - how to do it?
Posted by Martin Makundi <ma...@koodaripalvelut.com>.
We have (some key) entities (successfully) in Session. But they are
not lazy-load entities so they act like plain-old-java-beans.
**
Martin
2009/10/7 Jeffrey Schneller <je...@envisa.com>:
> Looking through the archives I saw some posts that said you should not
> store entity objects [for example object coming from hibernate] in the
> session. This makes sense to me as I just hit the problem.
>
> The archives gave lots of advice but everything seemed to contradict and
> no one posted a working solution.
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org