[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2650) Allow for an entire Session to be readOnly, add Session.setReadOnly() method

Eddy Soko (JIRA) noreply at atlassian.com
Mon Jan 26 05:07:39 EST 2009


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=32191#action_32191 ] 

Eddy Soko commented on HHH-2650:
--------------------------------

Can Session.setReadOnly() become Session.setReadOnly(Boolean setUnderlyingJDBCConnectionReadOnly) ?

Setting the underlying jdbc connection to readOnly can be used to send the query to a slave database and also to optimize the query itself in the db server.
Currently we have implemented this type of requirement by extending the ConnectionProvider where we check the value of a ThreadLocal.
This is not perfect because it associates a jdbc connection with a thread and not with a transaction. A thread can have multiple transactions (nested transactions).

We also tried to get hold of the underlying JDBC connection from within a transactional method by unwrapping the Proxy object which wraps the Connection from the current hibernate session. It worked, but we abandoned it cause session.connection() is going to be removed in hibernate 4.x and also manipulating the connection from ConnectionProvider seemed a better choice in case we moved to an XA-datasource.







> Allow for an entire Session to be readOnly, add Session.setReadOnly() method
> ----------------------------------------------------------------------------
>
>                 Key: HHH-2650
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2650
>             Project: Hibernate Core
>          Issue Type: Sub-task
>          Components: core
>         Environment: Any
>            Reporter: Gunther Schadow
>   Original Estimate: 1 day
>  Remaining Estimate: 1 day
>
> There is a need for read-only applications to avoid any snapshoting of objects if that application never intends to make updates. Such readOnly mode would be the mode in which any object gets loaded into the session, whether directly or from lazy collections. The use case is reporting applications which want to make sure that they don't even accidentally make updates AND that want to save the time it takes to create snapshots because they read through a lot of data very quickly. Our own need is that we have a rich client where we hold read only sessions open for browsing and where we spawn off any change transactions into separate Sessions. Even in change transactions we like to have all objects locked from even accidental updates unless they are explicitly unlocked.
> A Session.setReadOnly() method would be ideal to do this. It does not appear very hard to make that improvement. We would do it ourselves even if we had some idea if (and under which criteria) our modifications would have a chance to make it into future versions of Hibernate?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list