-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Session & HttpSession, best practice pattern
PostPosted: Fri Sep 03, 2004 5:31 am 
Beginner
Beginner

Joined: Thu Oct 09, 2003 11:41 am
Posts: 39
Location: Paris, France
Hello,

What would be best practice for the following pattern:

The user logs in.
The User object is retrieved and stored in the HttpSession.
Thereafter, we use the HttpSession-cached object unless we make changes to the User object.

I understand that the User record in the DB may change and the HttpSession object will not reflect the change.

How this would be best approached? It would be expensive (?) to update the User object every time that I open the Hibernate session.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 03, 2004 2:47 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
I prefer to store key in httpsession, it gives more options for cache and load balancing, fail tolerance, but you can create wrapper ("abstraction") for httprequest and it will be easy change it later if you will see some problem:

Quote:
class MyRequest {

User getUser(){

// you can have different implementations for HTTP or JMS
// return it form session or retrieve from cache/db by id

}


}

// new object per action, it will let to store state in fields.

abstract class MyCommand {

MyCommand(MyRequest request, MyResponse response ){
//copy params
}


abstract void execute();


final void doExecute(){
//pre execute
execute();
//post execute

}


}


There is no "session abstraction" in this wrapper, all session related attributes are encapsulated in request wrapper. It is not very hard to implement, is it ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.