Uploaded image for project: 'Hibernate ORM'
  1. HHH-9635

SQLServer2005Dialect (and above) does not support read past locking

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.3.8, 5.0.2
    • Fix Version/s: 5.1.0, 5.0.8
    • Component/s: None
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Suitable for new contributors:
      Yes, likely
    • Last commented by a user?:
      true
    • Sprint:

      Description

      When HHH-6736 Closed added support for read past locking, it only updated the base SQLServerDialect.appendLockHint method.

      That method was overridden in SQLServer2005Dialect but support for read past locking was not added to this method.

      A simple fix is to simply add support for LockMode.UPGRADE_SKIPLOCKED to the switch statement in SQLServer2005Dialect.

      An alternative fix is to replace SQLServer2005Dialect.appendLockMode with the following which avoids completely overriding the parent method (but requires a String.replace call):

      @Override
      public String appendLockHint(LockOptions lockOptions, String tableName) {
          String lockHint = super.appendLockHint(lockOptions, tableName);
      
          // NOTE : since SQLServer2005 the nowait hint is supported
          final boolean isNoWait = lockOptions.getTimeOut() == LockOptions.NO_WAIT;
          if ( isNoWait || lockOptions.getLockMode() == LockMode.UPGRADE_NOWAIT ) {
              lockHint = lockHint.replace("rowlock", "rowlock, nowait");
          }
      
          return lockHint;
      }
      

        Attachments

          Issue links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: