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

Peter Buning (JIRA) noreply at atlassian.com
Wed Oct 13 12:39:59 EDT 2010


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