开发者

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 ple开发者_StackOverflow中文版ase 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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜