Example usage for org.hibernate LockMode greaterThan

List of usage examples for org.hibernate LockMode greaterThan

Introduction

In this page you can find the example usage for org.hibernate LockMode greaterThan.

Prototype

public boolean greaterThan(LockMode mode) 

Source Link

Document

Check if this lock mode is more restrictive than the given lock mode.

Usage

From source file:com.ephesoft.dcma.da.common.EphesoftSQLServerDialect.java

License:Open Source License

/**
 * This method appends lock hint.//from w ww. java  2 s .  com
 * 
 * @param mode LockMode 
 * @param tableName {@link String}
 * @return {@link String}
 */
public String appendLockHint(LockMode mode, String tableName) {
    if (mode.greaterThan(LockMode.READ)) {
        // does this need holdlock also? : return tableName + " with (updlock, rowlock, holdlock)";
        return tableName + " with (updlock, rowlock)";
    } else {
        return tableName + " with (READCOMMITTED)";
    }
}

From source file:com.ephesoft.dcma.workflow.dialect.EphesoftSQLServerDialect.java

License:Open Source License

/**
 * To append Lock Hint./*from  www  .  ja v  a2  s . c om*/
 * 
 * @param mode LockMode
 * @param tableName String
 */
public String appendLockHint(LockMode mode, String tableName) {
    String lockHint;
    if (mode.greaterThan(LockMode.READ)) {
        // does this need holdlock also? : return tableName + " with (updlock, rowlock, holdlock)";
        lockHint = tableName + " with (updlock, rowlock)";
    } else {
        lockHint = tableName + " with (nolock)";
    }
    return lockHint;
}

From source file:hacks.VirtuosoSybaseDialect.java

License:Open Source License

public String appendLockHint(LockMode mode, String tableName) {
    if (mode.greaterThan(LockMode.READ)) {
        return tableName + " holdlock";
    } else {//from w w  w .j  a  v a  2  s.c  o m
        return tableName;
    }
}

From source file:hacks.VirtuosoSybaseDialect.java

License:Open Source License

@Override
public String applyLocksToSql(String sql, Map aliasedLockModes, Map keyColumnNames) {
    Iterator itr = aliasedLockModes.entrySet().iterator();
    StringBuffer buffer = new StringBuffer(sql);
    int correction = 0;
    while (itr.hasNext()) {
        final Map.Entry entry = (Map.Entry) itr.next();
        final LockMode lockMode = (LockMode) entry.getValue();
        if (lockMode.greaterThan(LockMode.READ)) {
            final String alias = (String) entry.getKey();
            int start = -1, end = -1;
            if (sql.endsWith(" " + alias)) {
                start = (sql.length() - alias.length()) + correction;
                end = start + alias.length();
            } else {
                int position = sql.indexOf(" " + alias + " ");
                if (position <= -1) {
                    position = sql.indexOf(" " + alias + ",");
                }/*  w  w w . j a v  a 2 s .  c  o m*/
                if (position > -1) {
                    start = position + correction + 1;
                    end = start + alias.length();
                }
            }

            if (start > -1) {
                final String lockHint = appendLockHint(lockMode, alias);
                buffer.replace(start, end, lockHint);
                correction += (lockHint.length() - alias.length());
            }
        }
    }
    return buffer.toString();
}