Java Code Examples for org.hibernate.LockMode#PESSIMISTIC_WRITE
The following examples show how to use
org.hibernate.LockMode#PESSIMISTIC_WRITE .
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: LockModeConverter.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Convert from the Hibernate specific LockMode to the JPA defined LockModeType. * * @param lockMode The Hibernate LockMode. * * @return The JPA LockModeType */ public static LockModeType convertToLockModeType(LockMode lockMode) { if ( lockMode == LockMode.NONE ) { return LockModeType.NONE; } else if ( lockMode == LockMode.OPTIMISTIC || lockMode == LockMode.READ ) { return LockModeType.OPTIMISTIC; } else if ( lockMode == LockMode.OPTIMISTIC_FORCE_INCREMENT || lockMode == LockMode.WRITE ) { return LockModeType.OPTIMISTIC_FORCE_INCREMENT; } else if ( lockMode == LockMode.PESSIMISTIC_READ ) { return LockModeType.PESSIMISTIC_READ; } else if ( lockMode == LockMode.PESSIMISTIC_WRITE || lockMode == LockMode.UPGRADE || lockMode == LockMode.UPGRADE_NOWAIT || lockMode == LockMode.UPGRADE_SKIPLOCKED) { return LockModeType.PESSIMISTIC_WRITE; } else if ( lockMode == LockMode.PESSIMISTIC_FORCE_INCREMENT || lockMode == LockMode.FORCE ) { return LockModeType.PESSIMISTIC_FORCE_INCREMENT; } throw new AssertionFailure( "unhandled lock mode " + lockMode ); }
Example 2
Source File: HSQLDialect.java From lams with GNU General Public License v2.0 | 6 votes |
/** * 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 3
Source File: Cache71Dialect.java From lams with GNU General Public License v2.0 | 6 votes |
@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 4
Source File: TimesTenDialect.java From lams with GNU General Public License v2.0 | 6 votes |
@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 5
Source File: PointbaseDialect.java From lams with GNU General Public License v2.0 | 6 votes |
@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 6
Source File: RDMSOS2200Dialect.java From lams with GNU General Public License v2.0 | 6 votes |
@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 7
Source File: MckoiDialect.java From lams with GNU General Public License v2.0 | 6 votes |
@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 8
Source File: FrontBaseDialect.java From lams with GNU General Public License v2.0 | 6 votes |
@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: TableGenerator.java From lams with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings({"unchecked", "WeakerAccess"}) protected String buildSelectQuery(Dialect dialect) { final String alias = "tbl"; final String query = "select " + StringHelper.qualify( alias, valueColumnName ) + " from " + renderedTableName + ' ' + alias + " where " + StringHelper.qualify( alias, segmentColumnName ) + "=?"; final LockOptions lockOptions = new LockOptions( LockMode.PESSIMISTIC_WRITE ); lockOptions.setAliasSpecificLockMode( alias, LockMode.PESSIMISTIC_WRITE ); final Map updateTargetColumnsMap = Collections.singletonMap( alias, new String[] { valueColumnName } ); return dialect.applyLocksToSql( query, lockOptions, updateTargetColumnsMap ); }
Example 10
Source File: LockModeConverter.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Convert from JPA defined LockModeType to Hibernate specific LockMode. * * @param lockMode The JPA LockModeType * * @return The Hibernate LockMode. */ public static LockMode convertToLockMode(LockModeType lockMode) { switch ( lockMode ) { case READ: case OPTIMISTIC: { return LockMode.OPTIMISTIC; } case OPTIMISTIC_FORCE_INCREMENT: case WRITE: { return LockMode.OPTIMISTIC_FORCE_INCREMENT; } case PESSIMISTIC_READ: { return LockMode.PESSIMISTIC_READ; } case PESSIMISTIC_WRITE: { return LockMode.PESSIMISTIC_WRITE; } case PESSIMISTIC_FORCE_INCREMENT: { return LockMode.PESSIMISTIC_FORCE_INCREMENT; } case NONE: { return LockMode.NONE; } default: { throw new AssertionFailure( "Unknown LockModeType: " + lockMode ); } } }