org.hibernate.dialect.lock.LockingStrategy Java Examples

The following examples show how to use org.hibernate.dialect.lock.LockingStrategy. 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: HSQLDialect.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * For HSQLDB 2.0, this is a copy of the base class implementation.
 * For HSQLDB 1.8, only READ_UNCOMMITTED is supported.
 * <p/>
 * {@inheritDoc}
 */
@Override
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
	if ( lockMode == LockMode.PESSIMISTIC_FORCE_INCREMENT ) {
		return new PessimisticForceIncrementLockingStrategy( lockable, lockMode );
	}
	else if ( lockMode == LockMode.PESSIMISTIC_WRITE ) {
		return new PessimisticWriteSelectLockingStrategy( lockable, lockMode );
	}
	else if ( lockMode == LockMode.PESSIMISTIC_READ ) {
		return new PessimisticReadSelectLockingStrategy( lockable, lockMode );
	}
	else if ( lockMode == LockMode.OPTIMISTIC ) {
		return new OptimisticLockingStrategy( lockable, lockMode );
	}
	else if ( lockMode == LockMode.OPTIMISTIC_FORCE_INCREMENT ) {
		return new OptimisticForceIncrementLockingStrategy( lockable, lockMode );
	}

	if ( hsqldbVersion < 200 ) {
		return new ReadUncommittedLockingStrategy( lockable, lockMode );
	}
	else {
		return new SelectLockingStrategy( lockable, lockMode );
	}
}
 
Example #2
Source File: Cache71Dialect.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
	// InterSystems Cache' does not current support "SELECT ... FOR UPDATE" syntax...
	// Set your transaction mode to READ_COMMITTED before using
	if ( lockMode==LockMode.PESSIMISTIC_FORCE_INCREMENT) {
		return new PessimisticForceIncrementLockingStrategy( lockable, lockMode);
	}
	else if ( lockMode==LockMode.PESSIMISTIC_WRITE) {
		return new PessimisticWriteUpdateLockingStrategy( lockable, lockMode);
	}
	else if ( lockMode==LockMode.PESSIMISTIC_READ) {
		return new PessimisticReadUpdateLockingStrategy( lockable, lockMode);
	}
	else if ( lockMode==LockMode.OPTIMISTIC) {
		return new OptimisticLockingStrategy( lockable, lockMode);
	}
	else if ( lockMode==LockMode.OPTIMISTIC_FORCE_INCREMENT) {
		return new OptimisticForceIncrementLockingStrategy( lockable, lockMode);
	}
	else if ( lockMode.greaterThan( LockMode.READ ) ) {
		return new UpdateLockingStrategy( lockable, lockMode );
	}
	else {
		return new SelectLockingStrategy( lockable, lockMode );
	}
}
 
Example #3
Source File: TimesTenDialect.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
	// TimesTen has no known variation of a "SELECT ... FOR UPDATE" syntax...
	if ( lockMode == LockMode.PESSIMISTIC_FORCE_INCREMENT ) {
		return new PessimisticForceIncrementLockingStrategy( lockable, lockMode );
	}
	else if ( lockMode == LockMode.PESSIMISTIC_WRITE ) {
		return new PessimisticWriteUpdateLockingStrategy( lockable, lockMode );
	}
	else if ( lockMode == LockMode.PESSIMISTIC_READ ) {
		return new PessimisticReadUpdateLockingStrategy( lockable, lockMode );
	}
	else if ( lockMode == LockMode.OPTIMISTIC ) {
		return new OptimisticLockingStrategy( lockable, lockMode );
	}
	else if ( lockMode == LockMode.OPTIMISTIC_FORCE_INCREMENT ) {
		return new OptimisticForceIncrementLockingStrategy( lockable, lockMode );
	}
	else if ( lockMode.greaterThan( LockMode.READ ) ) {
		return new UpdateLockingStrategy( lockable, lockMode );
	}
	else {
		return new SelectLockingStrategy( lockable, lockMode );
	}
}
 
Example #4
Source File: PointbaseDialect.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
	// Pointbase has no known variation of a "SELECT ... FOR UPDATE" syntax...
	if ( lockMode==LockMode.PESSIMISTIC_FORCE_INCREMENT) {
		return new PessimisticForceIncrementLockingStrategy( lockable, lockMode);
	}
	else if ( lockMode==LockMode.PESSIMISTIC_WRITE) {
		return new PessimisticWriteUpdateLockingStrategy( lockable, lockMode);
	}
	else if ( lockMode==LockMode.PESSIMISTIC_READ) {
		return new PessimisticReadUpdateLockingStrategy( lockable, lockMode);
	}
	else if ( lockMode==LockMode.OPTIMISTIC) {
		return new OptimisticLockingStrategy( lockable, lockMode);
	}
	else if ( lockMode==LockMode.OPTIMISTIC_FORCE_INCREMENT) {
		return new OptimisticForceIncrementLockingStrategy( lockable, lockMode);
	}
	else if ( lockMode.greaterThan( LockMode.READ ) ) {
		return new UpdateLockingStrategy( lockable, lockMode );
	}
	else {
		return new SelectLockingStrategy( lockable, lockMode );
	}
}
 
Example #5
Source File: RDMSOS2200Dialect.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
	// RDMS has no known variation of a "SELECT ... FOR UPDATE" syntax...
	if ( lockMode == LockMode.PESSIMISTIC_FORCE_INCREMENT ) {
		return new PessimisticForceIncrementLockingStrategy( lockable, lockMode );
	}
	else if ( lockMode == LockMode.PESSIMISTIC_WRITE ) {
		return new PessimisticWriteUpdateLockingStrategy( lockable, lockMode );
	}
	else if ( lockMode == LockMode.PESSIMISTIC_READ ) {
		return new PessimisticReadUpdateLockingStrategy( lockable, lockMode );
	}
	else if ( lockMode == LockMode.OPTIMISTIC ) {
		return new OptimisticLockingStrategy( lockable, lockMode );
	}
	else if ( lockMode == LockMode.OPTIMISTIC_FORCE_INCREMENT ) {
		return new OptimisticForceIncrementLockingStrategy( lockable, lockMode );
	}
	else if ( lockMode.greaterThan( LockMode.READ ) ) {
		return new UpdateLockingStrategy( lockable, lockMode );
	}
	else {
		return new SelectLockingStrategy( lockable, lockMode );
	}
}
 
Example #6
Source File: MckoiDialect.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
	// Mckoi has no known variation of a "SELECT ... FOR UPDATE" syntax...
	if ( lockMode==LockMode.PESSIMISTIC_FORCE_INCREMENT) {
		return new PessimisticForceIncrementLockingStrategy( lockable, lockMode);
	}
	else if ( lockMode==LockMode.PESSIMISTIC_WRITE) {
		return new PessimisticWriteUpdateLockingStrategy( lockable, lockMode);
	}
	else if ( lockMode==LockMode.PESSIMISTIC_READ) {
		return new PessimisticReadUpdateLockingStrategy( lockable, lockMode);
	}
	else if ( lockMode==LockMode.OPTIMISTIC) {
		return new OptimisticLockingStrategy( lockable, lockMode);
	}
	else if ( lockMode==LockMode.OPTIMISTIC_FORCE_INCREMENT) {
		return new OptimisticForceIncrementLockingStrategy( lockable, lockMode);
	}
	else if ( lockMode.greaterThan( LockMode.READ ) ) {
		return new UpdateLockingStrategy( lockable, lockMode );
	}
	else {
		return new SelectLockingStrategy( lockable, lockMode );
	}
}
 
Example #7
Source File: Dialect.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get a strategy instance which knows how to acquire a database-level lock
 * of the specified mode for this dialect.
 *
 * @param lockable The persister for the entity to be locked.
 * @param lockMode The type of lock to be acquired.
 * @return The appropriate locking strategy.
 * @since 3.2
 */
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
	switch ( lockMode ) {
		case PESSIMISTIC_FORCE_INCREMENT:
			return new PessimisticForceIncrementLockingStrategy( lockable, lockMode );
		case PESSIMISTIC_WRITE:
			return new PessimisticWriteSelectLockingStrategy( lockable, lockMode );
		case PESSIMISTIC_READ:
			return new PessimisticReadSelectLockingStrategy( lockable, lockMode );
		case OPTIMISTIC:
			return new OptimisticLockingStrategy( lockable, lockMode );
		case OPTIMISTIC_FORCE_INCREMENT:
			return new OptimisticForceIncrementLockingStrategy( lockable, lockMode );
		default:
			return new SelectLockingStrategy( lockable, lockMode );
	}
}
 
Example #8
Source File: FrontBaseDialect.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
	// Frontbase has no known variation of a "SELECT ... FOR UPDATE" syntax...
	if ( lockMode==LockMode.PESSIMISTIC_FORCE_INCREMENT) {
		return new PessimisticForceIncrementLockingStrategy( lockable, lockMode);
	}
	else if ( lockMode==LockMode.PESSIMISTIC_WRITE) {
		return new PessimisticWriteUpdateLockingStrategy( lockable, lockMode);
	}
	else if ( lockMode==LockMode.PESSIMISTIC_READ) {
		return new PessimisticReadUpdateLockingStrategy( lockable, lockMode);
	}
	else if ( lockMode==LockMode.OPTIMISTIC) {
		return new OptimisticLockingStrategy( lockable, lockMode);
	}
	else if ( lockMode==LockMode.OPTIMISTIC_FORCE_INCREMENT) {
		return new OptimisticForceIncrementLockingStrategy( lockable, lockMode);
	}
	else if ( lockMode.greaterThan( LockMode.READ ) ) {
		return new UpdateLockingStrategy( lockable, lockMode );
	}
	else {
		return new SelectLockingStrategy( lockable, lockMode );
	}
}
 
Example #9
Source File: IgniteDialect.java    From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
	if ( lockMode == LockMode.PESSIMISTIC_FORCE_INCREMENT ) {
		return new PessimisticForceIncrementLockingStrategy( lockable, lockMode );
	}
	// else if ( lockMode==LockMode.PESSIMISTIC_WRITE ) {
	// return new PessimisticWriteLockingStrategy( lockable, lockMode );
	// }
	else if ( lockMode == LockMode.PESSIMISTIC_READ ) {
		return new IgnitePessimisticReadLockingStrategy( lockable, lockMode, provider );
	}
	else if ( lockMode == LockMode.OPTIMISTIC ) {
		return new OptimisticLockingStrategy( lockable, lockMode );
	}
	else if ( lockMode == LockMode.OPTIMISTIC_FORCE_INCREMENT ) {
		return new OptimisticForceIncrementLockingStrategy( lockable, lockMode );
	}
	else {
		return null;
	}
}
 
Example #10
Source File: TimesTenDialect.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
	// TimesTen has no known variation of a "SELECT ... FOR UPDATE" syntax...
	if ( lockMode.greaterThan( LockMode.READ ) ) {
		return new UpdateLockingStrategy( lockable, lockMode );
	}
	else {
		return new SelectLockingStrategy( lockable, lockMode );
	}
}
 
Example #11
Source File: Cache71Dialect.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
	// InterSystems Cache' does not current support "SELECT ... FOR UPDATE" syntax...
	// Set your transaction mode to READ_COMMITTED before using
	if ( lockMode.greaterThan( LockMode.READ ) ) {
		return new UpdateLockingStrategy( lockable, lockMode );
	}
	else {
		return new SelectLockingStrategy( lockable, lockMode );
	}
}
 
Example #12
Source File: PointbaseDialect.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
	// Pointbase has no known variation of a "SELECT ... FOR UPDATE" syntax...
	if ( lockMode.greaterThan( LockMode.READ ) ) {
		return new UpdateLockingStrategy( lockable, lockMode );
	}
	else {
		return new SelectLockingStrategy( lockable, lockMode );
	}
}
 
Example #13
Source File: RDMSOS2200Dialect.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
	// RDMS has no known variation of a "SELECT ... FOR UPDATE" syntax...
	if ( lockMode.greaterThan( LockMode.READ ) ) {
		return new UpdateLockingStrategy( lockable, lockMode );
	}
	else {
		return new SelectLockingStrategy( lockable, lockMode );
	}
}
 
Example #14
Source File: MckoiDialect.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
	// Mckoi has no known variation of a "SELECT ... FOR UPDATE" syntax...
	if ( lockMode.greaterThan( LockMode.READ ) ) {
		return new UpdateLockingStrategy( lockable, lockMode );
	}
	else {
		return new SelectLockingStrategy( lockable, lockMode );
	}
}
 
Example #15
Source File: FrontBaseDialect.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
	// Frontbase has no known variation of a "SELECT ... FOR UPDATE" syntax...
	if ( lockMode.greaterThan( LockMode.READ ) ) {
		return new UpdateLockingStrategy( lockable, lockMode );
	}
	else {
		return new SelectLockingStrategy( lockable, lockMode );
	}
}
 
Example #16
Source File: SpannerDialect.java    From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
  return LOCKING_STRATEGY;
}
 
Example #17
Source File: DelegatingDialect.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public LockingStrategy getLockingStrategy(Lockable lockable,
        LockMode lockMode) {
    return getInstance().getLockingStrategy(lockable, lockMode);
}
 
Example #18
Source File: HSQLDialect.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
	// HSQLDB only supports READ_UNCOMMITTED transaction isolation
	return new ReadUncommittedLockingStrategy( lockable, lockMode );
}
 
Example #19
Source File: AbstractEntityPersister.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private LockingStrategy getLocker(LockMode lockMode) {
	return ( LockingStrategy ) lockers.get( lockMode );
}
 
Example #20
Source File: AbstractEntityPersister.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected LockingStrategy generateLocker(LockMode lockMode) {
	return factory.getDialect().getLockingStrategy( this, lockMode );
}
 
Example #21
Source File: AbstractEntityPersister.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
private LockingStrategy getLocker(LockMode lockMode) {
	return (LockingStrategy) lockers.get( lockMode );
}
 
Example #22
Source File: AbstractEntityPersister.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
protected LockingStrategy generateLocker(LockMode lockMode) {
	return factory.getDialect().getLockingStrategy( this, lockMode );
}
 
Example #23
Source File: Dialect.java    From cacheonix-core with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Get a strategy instance which knows how to acquire a database-level lock
 * of the specified mode for this dialect.
 *
 * @param lockable The persister for the entity to be locked.
 * @param lockMode The type of lock to be acquired.
 * @return The appropriate locking strategy.
 * @since 3.2
 */
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
	return new SelectLockingStrategy( lockable, lockMode );
}