本文整理汇总了Java中org.hibernate.LockOptions.NO_WAIT属性的典型用法代码示例。如果您正苦于以下问题:Java LockOptions.NO_WAIT属性的具体用法?Java LockOptions.NO_WAIT怎么用?Java LockOptions.NO_WAIT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.hibernate.LockOptions
的用法示例。
在下文中一共展示了LockOptions.NO_WAIT属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: appendLockHint
@Override
public String appendLockHint(LockOptions lockOptions, String tableName) {
// NOTE : since SQLServer2005 the nowait hint is supported
if ( lockOptions.getLockMode() == LockMode.UPGRADE_NOWAIT ) {
return tableName + " with (updlock, rowlock, nowait)";
}
final LockMode mode = lockOptions.getLockMode();
final boolean isNoWait = lockOptions.getTimeOut() == LockOptions.NO_WAIT;
final String noWaitStr = isNoWait ? ", nowait" : "";
switch ( mode ) {
case UPGRADE_NOWAIT:
return tableName + " with (updlock, rowlock, nowait)";
case UPGRADE:
case PESSIMISTIC_WRITE:
case WRITE:
return tableName + " with (updlock, rowlock" + noWaitStr + " )";
case PESSIMISTIC_READ:
return tableName + " with (holdlock, rowlock" + noWaitStr + " )";
default:
return tableName;
}
}
示例2: determineSql
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 );
}
}
示例3: getWriteLockString
@Override
public String getWriteLockString(int timeout) {
if ( timeout == LockOptions.NO_WAIT ) {
return " for update nowait";
}
else {
return " for update";
}
}
示例4: getReadLockString
@Override
public String getReadLockString(int timeout) {
if ( timeout == LockOptions.NO_WAIT ) {
return " for share nowait";
}
else {
return " for share";
}
}
示例5: getWriteLockString
@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";
}
}