简体   繁体   中英

Need enough information about stateless session in hibernate

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

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

The book Java Persistence with Hibernate has a short, but sufficient section about stateless session in Hibernate. If you do not want to buy a copy of that book just for that information, I found the whole book on slideshare.com ; Section 12.2.3, page 539 (page 574 on slideshare.com).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM