Hi
I am working on hibernate and need some information about the stateless session. tried to search on google but didnt get that much information. so please need any link or pdf’s about stateless session on how, why and when to use it. what are the pros and cons of using it.
thanks
Hi I am working on hibernate and need some information about the stateless session.
Share
There isn’t much to say about Stateless Sessions, anyway. Basically, it serves only one purpose: to not cache anything at all.
In regular sessions, Hibernate maintains a “session-level cache”, which is cleared when you close your session, for instance. In some other cases, you can plug a caching mechanism to act as a “second level cache”, which is complimentary to this “session-level cache” and can survive even after a session is closed.
However, this can be a problem if you are in a batch-operation mode. For instance, it doesn’t makes sense to keep any entity in the cache (session-level) if you are just reading an input file and inserting entities in the database. You know you won’t need that entity anymore. So, that’s where you use the Stateless session.
There’s no change in the API, just changes in the implementation.
Take a look at this link. This is all you need to know about Stateless Sessions:
http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/batch.html#batch-statelesssession