`
echohfut
  • 浏览: 234108 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

hibernate session 管理

 
阅读更多

1. Session per Operation (Anti pattern)

 

2. Session per Request

use "Open Session In View" when rendering layer seperate from servlet, e.g. in JSP

 

3. Session per Request with detached object

when a user case spans several transaction, considering the user think time, we can detach and re-attach

the object to different session. Here we mean one session on transaction. For making sure only one user modifying that data, we need to user optimistic lock such as automatic versioning to isolate business use case.

 

4. Session per Conversation

the Hibernate Session can be disconnected from the underlying JDBC connection after the database transaction has been committed and reconnected when a new client request occurs. This pattern is known as session-per-conversation and makes even reattachment unnecessary. Automatic versioning is used to isolate concurrent modifications and the Session will not be allowed to be flushed automatically, but explicitly.

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics