From: Matthias G. (JIRA) <no...@at...> - 2006-07-08 12:45:57
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1889?page=comments#action_23578 ] Matthias Germann commented on HHH-1889: --------------------------------------- The LockMode.UPGRADE does also not work for SQL Server with the Query by Criteria API: session.createCriteria(ProcessInstance.class) .add(Restrictions.idEq(33l)) .setFetchMode("rootToken", FetchMode.JOIN) .createAlias("rootToken", "rootToken") .setLockMode("rootToken", LockMode.UPGRADE) .list(); proces the following SQL Statement with the SQLServer dialect: select this_.ID_ as ID1_20_1_, this_.VERSION_ as VERSION2_20_1_, this_.START_ as START3_20_1_, this_.END_ as END4_20_1_, this_.ISSUSPENDED_ as ISSUSPEN5_20_1_, this_.PROCESSDEFINITION_ as PROCESSD6_20_1_, this_.ROOTTOKEN_ as ROOTTOKEN7_20_1_, this_.SUPERPROCESSTOKEN_ as SUPERPRO8_20_1_, roottoken1_.ID_ as ID1_21_0_, roottoken1_.VERSION_ as VERSION2_21_0_, roottoken1_.NAME_ as NAME3_21_0_, roottoken1_.START_ as START4_21_0_, roottoken1_.END_ as END5_21_0_, roottoken1_.NODEENTER_ as NODEENTER6_21_0_, roottoken1_.NEXTLOGINDEX_ as NEXTLOGI7_21_0_, roottoken1_.ISABLETOREACTIVATEPARENT_ as ISABLETO8_21_0_, roottoken1_.ISTERMINATIONIMPLICIT_ as ISTERMIN9_21_0_, roottoken1_.ISSUSPENDED_ as ISSUSPE10_21_0_, roottoken1_.NODE_ as NODE11_21_0_, roottoken1_.PROCESSINSTANCE_ as PROCESS12_21_0_, roottoken1_.PARENT_ as PARENT13_21_0_, roottoken1_.SUBPROCESSINSTANCE_ as SUBPROC14_21_0_ from JBPM_PROCESSINSTANCE this_ inner join JBPM_TOKEN roottoken1_ on this_.ROOTTOKEN_=roottoken1_.ID_ where this_.ID_ = ? Again, the lock hint is missing. The OracleDialect produces a correct Statement with the lock clause: select this_.ID_ as ID1_20_1_, this_.VERSION_ as VERSION2_20_1_, this_.START_ as START3_20_1_, this_.END_ as END4_20_1_, this_.ISSUSPENDED_ as ISSUSPEN5_20_1_, this_.PROCESSDEFINITION_ as PROCESSD6_20_1_, this_.ROOTTOKEN_ as ROOTTOKEN7_20_1_, this_.SUPERPROCESSTOKEN_ as SUPERPRO8_20_1_, roottoken1_.ID_ as ID1_21_0_, roottoken1_.VERSION_ as VERSION2_21_0_, roottoken1_.NAME_ as NAME3_21_0_, roottoken1_.START_ as START4_21_0_, roottoken1_.END_ as END5_21_0_, roottoken1_.NODEENTER_ as NODEENTER6_21_0_, roottoken1_.NEXTLOGINDEX_ as NEXTLOGI7_21_0_, roottoken1_.ISABLETOREACTIVATEPARENT_ as ISABLETO8_21_0_, roottoken1_.ISTERMINATIONIMPLICIT_ as ISTERMIN9_21_0_, roottoken1_.ISSUSPENDED_ as ISSUSPE10_21_0_, roottoken1_.NODE_ as NODE11_21_0_, roottoken1_.PROCESSINSTANCE_ as PROCESS12_21_0_, roottoken1_.PARENT_ as PARENT13_21_0_, roottoken1_.SUBPROCESSINSTANCE_ as SUBPROC14_21_0_ from JBPM_PROCESSINSTANCE this_, JBPM_TOKEN roottoken1_ where this_.ROOTTOKEN_=roottoken1_.ID_ and this_.ID_ = ? for update of roottoken1_.ID_ > LockMode.UPGRADE does not work for get(), load() and refresh() on SQL Server > ---------------------------------------------------------------------------- > > Key: HHH-1889 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1889 > Project: Hibernate3 > Type: Bug > Components: core > Versions: 3.2.0.cr2, 3.2.0.cr3 > Environment: Windows XP, Hibernate 3.2.cr3 > Reporter: Matthias Germann > Priority: Critical > > > Passing a LockMode parameter to the get(), load() or refresh() method of the Session class has no effect on MS SQL Server. > The statement > session.load(ProcessInstance.class, 33l, LockMode.UPGRADE) > produces this SQL Statement with the SQLServerDialect: > select > processins0_.ID_ as ID1_20_0_, > processins0_.VERSION_ as VERSION2_20_0_, > processins0_.START_ as START3_20_0_, > processins0_.END_ as END4_20_0_, > processins0_.ISSUSPENDED_ as ISSUSPEN5_20_0_, > processins0_.PROCESSDEFINITION_ as PROCESSD6_20_0_, > processins0_.ROOTTOKEN_ as ROOTTOKEN7_20_0_, > processins0_.SUPERPROCESSTOKEN_ as SUPERPRO8_20_0_ > from > JBPM_PROCESSINSTANCE processins0_ > where > processins0_.ID_=? > This Statement does not contain the requested locking hint. The FROM claus should look like this: > from JBPM_PROCESSINSTANCE processins0_ with (updlock, rowlock) > The OracleDialect produces a correct statement with a FOR UPDATE clause > select > processins0_.ID_ as ID1_20_0_, > processins0_.VERSION_ as VERSION2_20_0_, > processins0_.START_ as START3_20_0_, > processins0_.END_ as END4_20_0_, > processins0_.ISSUSPENDED_ as ISSUSPEN5_20_0_, > processins0_.PROCESSDEFINITION_ as PROCESSD6_20_0_, > processins0_.ROOTTOKEN_ as ROOTTOKEN7_20_0_, > processins0_.SUPERPROCESSTOKEN_ as SUPERPRO8_20_0_ > from > JBPM_PROCESSINSTANCE processins0_ > where > processins0_.ID_=? for update > The lock() method works correctly. > IMHO, the problem is that only the SimpleSelect class uses the appendLockHint() method of the Dialect class. The Select class does not seam to use the appendLockHint() method. -- 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 |