public MapPessimisticWriteLockingStrategy(Lockable lockable, LockMode lockMode) {
   this.lockable = lockable;
   this.lockMode = lockMode;
   TypeTranslator typeTranslator =
       lockable.getFactory().getServiceRegistry().getService(TypeTranslator.class);
   this.identifierGridType = typeTranslator.getType(lockable.getIdentifierType());
 }
 protected String generateLockString() {
   SessionFactoryImplementor factory = lockable.getFactory();
   Update update = new Update(factory.getDialect());
   update.setTableName(lockable.getRootTableName());
   update.addPrimaryKeyColumns(lockable.getRootTableIdentifierColumnNames());
   update.setVersionColumnName(lockable.getVersionColumnName());
   update.addColumn(lockable.getVersionColumnName());
   if (factory.getSettings().isCommentsEnabled()) {
     update.setComment(lockMode + " lock " + lockable.getEntityName());
   }
   return update.toStatementString();
 }
예제 #3
0
 protected String generateLockString() {
   SessionFactoryImplementor factory = lockable.getFactory();
   SimpleSelect select =
       new SimpleSelect(factory.getDialect())
           .setLockMode(lockMode)
           .setTableName(lockable.getRootTableName())
           .addColumn(lockable.getRootTableIdentifierColumnNames()[0])
           .addCondition(lockable.getRootTableIdentifierColumnNames(), "=?");
   if (lockable.isVersioned()) {
     select.addCondition(lockable.getVersionColumnName(), "=?");
   }
   if (factory.getSettings().isCommentsEnabled()) {
     select.setComment(lockMode + " lock " + lockable.getEntityName());
   }
   return select.toStatementString();
 }