[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5654) query.setLockMode("alias", LockMode.LockMode.PESSIMISTIC_WRITE); does not Lock in PostgreSqlDialect

James Reitz (JIRA) noreply at atlassian.com
Tue May 24 16:17:25 EDT 2011


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

James Reitz commented on HHH-5654:
----------------------------------

We also experienced this same problem with Hibernate 3.5.4-Final, Oracle 11g, and LockMode.UPGRADE_NOWAIT.  The interesting thing is that session.getCurrentLockMode(entity) showed the desired lock mode, but the query was never issued with the correct "for update nowait" syntax.

> query.setLockMode("alias", LockMode.LockMode.PESSIMISTIC_WRITE); does not Lock in PostgreSqlDialect
> ---------------------------------------------------------------------------------------------------
>
>                 Key: HHH-5654
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5654
>             Project: Hibernate Core
>          Issue Type: Bug
>    Affects Versions: 3.5.5
>         Environment: Hibernate 3.5.5-Final
> PostgreSQL 8.4
>            Reporter: Peter Buning
>
> When you call 
> {{query.setLockMode("alias", LockMode.PESSIMISTIC_WRITE);}}
> you get a Query with a LockOptions object that has lockMode = LockMode.NONE and a aliasSpecificLockModes-map with an entry "alias" -> LockMode.PESSIMISTIC_WRITE
> When calling {{query.list()}} you get to the QueryLoader which calls {{dialect.applyLocksToSql(...)}}
> The LockOptions-Object has still lockMode=LockMode.NONE and a aliasSpecificLockModes-map with the translated alias and -> LockMode.PESSIMISTIC_WRITE
> As we use PostgreSQL dialect is an instance of PostgreSQLDialect.
> So you get a ForUpdateFragement-object with the same LockOptions-object. The aliases-String contains the translated "alias".
> In  {{toFragmentString()}}  {{getForUpdateString(String aliases, LockOptions lockOptions)}} is called because we have a LockOptions-object. The aliases are ignored in this case, as you can see in the comment:'by default we simply return the getForUpdateString() result since the default is to say no support for "FOR UPDATE OF ..."'
> But the {{getForUpdateString(LockOptions lockOptions)}} is only looking at the the lockMode-Attribute of the LockOptions-object what has still the value "LockMode.NONE". It results in an empty String as the return value. But it should be " for update" because there's a LockMode.PESSIMISTIC_WRITE in the aliasSpecificLockModes which is ignored in getForUpdateString(LockOptions lockOptions)
>  

-- 
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