-->
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.  [ 4 posts ] 
Author Message
 Post subject: Rely on Hibernate cache, or store in session
PostPosted: Mon Dec 29, 2003 12:50 pm 
Beginner
Beginner

Joined: Sat Dec 20, 2003 5:09 pm
Posts: 38
Wondering what the recommended approach would be in a web application that constantly refers to data in a single table - like a user table.

Should I:

1) Put the individual pieces of data into the container's (Tomcat) session and refer to them there.
2) Store the Hibernate ID - that references the proper Hibernate persistant class - in the Tomcat session. Then everytime I need to refer to user info, do a lookup on the ID ....
3) Store the Hibernate java bean itself in Tomcat's session, and not even deal with the look-up.
4) Something else I'm not aware of.

Thanks in advance for the advice!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 29, 2003 12:57 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
For something like "logged in user", I would load the Object once and store it in the session. Do not use the session as a caching mechanism however, thats not really what it is for. Use the session for what it is intendet, associating objects with the "current user". For caching, use a cache.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 29, 2003 1:04 pm 
Beginner
Beginner

Joined: Sat Dec 20, 2003 5:09 pm
Posts: 38
Thanks!

I guess my choice of words wasn't the best - I didn't really mean cache. Like you described, all I want is quick reference to data associated with the currently logged in user.

So store the Hibernate java bean directly in the container's session. Sounds good to me.

Hmm, although that would mean I should make the java bean serializable. Doing that should be OK as far as HIbernate is concerned, right?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 29, 2003 1:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Hibernate doesn't mind if your beans are serializable or not


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.