[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5654?page=c...
]
Peter Buning edited comment on HHH-5654 at 11/12/10 2:48 AM:
-------------------------------------------------------------
it works with
query.setLockOptions(new LockOptions(LockMode.PESSIMISTIC_WRITE));
instead of
query.setLockMode("alias", LockMode.PESSIMISTIC_WRITE);
But, in this case the LockMode is not only used for "alias".
query.setLockOptions(new LockOptions("alias", LockMode.PESSIMISTIC_WRITE));
should work, too. We didn't try, because it wasn't necessary for us.
was (Author: buninho):
it works with
query.setLockOptions(new LockOptions(LockMode.PESSIMISTIC_WRITE));
instead of
query.setLockMode("alias", LockMode.PESSIMISTIC_WRITE);
But, in this case the LockMode ist used not only for "alias".
query.setLockOptions(new LockOptions("alias", LockMode.PESSIMISTIC_WRITE));
should work, too. We didn't try, because it wasn't necessary for us.
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira