Java Code Examples for org.hibernate.LockOptions#NO_WAIT

The following examples show how to use org.hibernate.LockOptions#NO_WAIT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MySQL8Dialect.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String getWriteLockString(int timeout) {
	if ( timeout == LockOptions.NO_WAIT ) {
		return getForUpdateNowaitString();
	}
	else if ( timeout == LockOptions.SKIP_LOCKED ) {
		return getForUpdateSkipLockedString();
	}
	return super.getWriteLockString( timeout );
}
 
Example 2
Source File: MySQL8Dialect.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String getWriteLockString(String aliases, int timeout) {
	if ( timeout == LockOptions.NO_WAIT ) {
		return getForUpdateNowaitString(aliases);
	}
	else if ( timeout == LockOptions.SKIP_LOCKED ) {
		return getForUpdateSkipLockedString(aliases);
	}
	return super.getWriteLockString( aliases, timeout );
}
 
Example 3
Source File: MySQL8Dialect.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String getReadLockString(int timeout) {
	String readLockString =  " for share";
	if ( timeout == LockOptions.NO_WAIT ) {
		return readLockString + " nowait ";
	}
	else if ( timeout == LockOptions.SKIP_LOCKED ) {
		return readLockString + " skip locked ";
	}
	return readLockString;
}
 
Example 4
Source File: MySQL8Dialect.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String getReadLockString(String aliases, int timeout) {
	String readLockString = String.format( " for share of %s ", aliases );
	if ( timeout == LockOptions.NO_WAIT ) {
		return readLockString + " nowait ";
	}
	else if ( timeout == LockOptions.SKIP_LOCKED ) {
		return readLockString + " skip locked ";
	}
	return readLockString;
}
 
Example 5
Source File: Teradata14Dialect.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String getWriteLockString(int timeout) {
	String sMsg = " Locking row for write ";
	if ( timeout == LockOptions.NO_WAIT ) {
		return sMsg + " nowait ";
	}
	return sMsg;
}
 
Example 6
Source File: Teradata14Dialect.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String getReadLockString(int timeout) {
	String sMsg = " Locking row for read  ";
	if ( timeout == LockOptions.NO_WAIT ) {
		return sMsg + " nowait ";
	}
	return sMsg;
}
 
Example 7
Source File: MariaDB103Dialect.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String getWriteLockString(int timeout) {
	if ( timeout == LockOptions.NO_WAIT ) {
		return getForUpdateNowaitString();
	}

	if ( timeout > 0 ) {
		return getForUpdateString() + " wait " + timeout;
	}

	return getForUpdateString();
}
 
Example 8
Source File: AbstractSelectLockingStrategy.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
protected String determineSql(int timeout) {
	if ( timeout == LockOptions.WAIT_FOREVER) {
		return waitForeverSql;
	}
	else if ( timeout == LockOptions.NO_WAIT) {
		return getNoWaitSql();
	}
	else if ( timeout == LockOptions.SKIP_LOCKED) {
		return getSkipLockedSql();
	}
	else {
		return generateLockString( timeout );
	}
}
 
Example 9
Source File: SQLServer2005Dialect.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String appendLockHint(LockOptions lockOptions, String tableName) {

	LockMode lockMode = lockOptions.getAliasSpecificLockMode( tableName );
	if(lockMode == null) {
		lockMode = lockOptions.getLockMode();
	}

	final String writeLockStr = lockOptions.getTimeOut() == LockOptions.SKIP_LOCKED ? "updlock" : "updlock, holdlock";
	final String readLockStr = lockOptions.getTimeOut() == LockOptions.SKIP_LOCKED ? "updlock" : "holdlock";

	final String noWaitStr = lockOptions.getTimeOut() == LockOptions.NO_WAIT ? ", nowait" : "";
	final String skipLockStr = lockOptions.getTimeOut() == LockOptions.SKIP_LOCKED ? ", readpast" : "";

	switch ( lockMode ) {
		case UPGRADE:
		case PESSIMISTIC_WRITE:
		case WRITE: {
			return tableName + " with (" + writeLockStr + ", rowlock" + noWaitStr + skipLockStr + ")";
		}
		case PESSIMISTIC_READ: {
			return tableName + " with (" + readLockStr + ", rowlock" + noWaitStr + skipLockStr + ")";
		}
		case UPGRADE_SKIPLOCKED:
			return tableName + " with (updlock, rowlock, readpast" + noWaitStr + ")";
		case UPGRADE_NOWAIT:
			return tableName + " with (updlock, holdlock, rowlock, nowait)";
		default: {
			return tableName;
		}
	}
}
 
Example 10
Source File: PostgreSQL81Dialect.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String getWriteLockString(int timeout) {
	if ( timeout == LockOptions.NO_WAIT ) {
		return " for update nowait";
	}
	else {
		return " for update";
	}
}
 
Example 11
Source File: PostgreSQL81Dialect.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String getWriteLockString(String aliases, int timeout) {
	if ( timeout == LockOptions.NO_WAIT ) {
		return String.format( " for update of %s nowait", aliases );
	}
	else {
		return " for update of " + aliases;
	}
}
 
Example 12
Source File: PostgreSQL81Dialect.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String getReadLockString(int timeout) {
	if ( timeout == LockOptions.NO_WAIT ) {
		return " for share nowait";
	}
	else {
		return " for share";
	}
}
 
Example 13
Source File: PostgreSQL81Dialect.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String getReadLockString(String aliases, int timeout) {
	if ( timeout == LockOptions.NO_WAIT ) {
		return String.format( " for share of %s nowait", aliases );
	}
	else {
		return " for share of " + aliases;
	}
}
 
Example 14
Source File: Oracle9iDialect.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String getWriteLockString(int timeout) {
	if ( timeout == LockOptions.NO_WAIT ) {
		return " for update nowait";
	}
	else if ( timeout > 0 ) {
		// convert from milliseconds to seconds
		final float seconds = timeout / 1000.0f;
		timeout = Math.round( seconds );
		return " for update wait " + timeout;
	}
	else {
		return " for update";
	}
}