File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Hibernate Long Session and First Level Cache behaviour Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate Long Session and First Level Cache behaviour" Watch "Hibernate Long Session and First Level Cache behaviour" New topic
Author

Hibernate Long Session and First Level Cache behaviour

Adrian
Greenhorn

Joined: Jul 26, 2005
Posts: 2
Hi,

We are working on a Web Application project, using the concept of "long sessions".
In this process we experienced an unexpected behaviour of the Hibernate Session:

- we store the Hibernate Session in the HttpSession.
- in consecutive requests we are connecting and disconnecting from the Hibernate Session.

- we were expecting that an object, once loaded in the Hibernate Session, will remain loaded as long as the Session is not closed.

However we found out that this is true, only when the "think time" is very short.

If "think time" is longer, when we reconnect to the session in the next request, the object is no longer available and a new database query is issued.

Is this the intended behaviour of Session cache, or we are doing something wrong?
Adrian
Greenhorn

Joined: Jul 26, 2005
Posts: 2
...after one more review of the code --> beginners mistake in the HibernateUtil class.

Session Cache works perfectly!!!
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

"Adrian"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the

JavaRanch Naming Policy.

You can change it

here.

Thanks! and welcome to the JavaRanch!

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate Long Session and First Level Cache behaviour