Hi, i have a problem on finding the more suitable session handling mechanism acording to my needs.
I first created a class that returns a thread-safe hibernate session. It is a copy of JPA PersistenceService class, i'm not using JPA but just hibernate.
But to solve the problem of performance i put my thread-safe session into http-session so i can share the same session across multiple request of the same http-session. I have an extra problem there because that way my hibernate session is now shared among different threads.
After that i found my sessions cache's get out of date because they know nothing about other session's transactions, see my previous post here:
http://forum.hibernate.org/viewtopic.php?t=991907
I could solve my problem by creating a new session every time a new request take place but that would have a poor performance.
Also i don't know if a second level cache can solve my problem and how.
So i am very confused.
What i want is to achieve a good performance but to get always my last changes.
I guess it is not a crazy thing what i want, just to have an hibernate session alive along the http-session lifetime, preventing threading problems and having my data always updated from the database.
Do anybody know which is the best way of handling my hibernate sessions?
Thanks.