protected String generateLockString() { final SessionFactoryImplementor factory = lockable.getFactory(); final Update update = new Update( factory.getDialect() ); update.setTableName( lockable.getRootTableName() ); update.addPrimaryKeyColumns( lockable.getRootTableIdentifierColumnNames() ); update.setVersionColumnName( lockable.getVersionColumnName() ); update.addColumn( lockable.getVersionColumnName() ); if ( factory.getSessionFactoryOptions().isCommentsEnabled() ) { update.setComment( lockMode + " lock " + lockable.getEntityName() ); } return update.toStatementString(); }
int timeout, SharedSessionContractImplementor session) throws StaleObjectStateException, JDBCException { if ( !lockable.isVersioned() ) { throw new HibernateException( "write locks via update not supported for non-versioned entities [" + lockable.getEntityName() + "]" ); final PreparedStatement st = session.getJdbcCoordinator().getStatementPreparer().prepareStatement( sql ); try { lockable.getVersionType().nullSafeSet( st, version, 1, session ); int offset = 2; lockable.getIdentifierType().nullSafeSet( st, id, offset, session ); offset += lockable.getIdentifierType().getColumnSpan( factory ); if ( lockable.isVersioned() ) { lockable.getVersionType().nullSafeSet( st, version, offset, session ); if ( affected < 0 ) { if (factory.getStatistics().isStatisticsEnabled()) { factory.getStatistics().optimisticFailure( lockable.getEntityName() ); throw new StaleObjectStateException( lockable.getEntityName(), id );
.findFromElementByUserOrSqlAlias( userAlias, drivingSqlAlias ) .getQueryable(); final String sqlAlias = drivingPersister.getRootTableAlias( drivingSqlAlias ); keyColumnNames.put( sqlAlias, drivingPersister.getRootTableIdentifierColumnNames() );
/** * Construct a locking strategy based on SQL UPDATE statements. * * @param lockable The metadata for the entity to be locked. * @param lockMode Indictates the type of lock to be acquired. Note that * read-locks are not valid for this strategy. */ public UpdateLockingStrategy(Lockable lockable, LockMode lockMode) { this.lockable = lockable; this.lockMode = lockMode; if ( lockMode.lessThan( LockMode.UPGRADE ) ) { throw new HibernateException( "[" + lockMode + "] not valid for update statement" ); } if ( !lockable.isVersioned() ) { LOG.writeLocksNotSupported( lockable.getEntityName() ); this.sql = null; } else { this.sql = generateLockString(); } }
public InfinispanPessimisticWriteLockingStrategy(Lockable lockable, LockMode lockMode) { this.lockMode = lockMode; this.lockable = lockable; TypeTranslator typeTranslator = lockable.getFactory().getServiceRegistry().getService( TypeTranslator.class ); this.identifierGridType = typeTranslator.getType( lockable.getIdentifierType() ); provider = getProvider( lockable.getFactory() ); }
/** * Construct locking strategy. * * @param lockable The metadata for the entity to be locked. * @param lockMode Indicates the type of lock to be acquired. */ public OptimisticLockingStrategy(Lockable lockable, LockMode lockMode) { this.lockable = lockable; this.lockMode = lockMode; if ( lockMode.lessThan( LockMode.OPTIMISTIC ) ) { throw new HibernateException( "[" + lockMode + "] not valid for [" + lockable.getEntityName() + "]" ); } }
/** * Construct a locking strategy based on SQL UPDATE statements. * * @param lockable The metadata for the entity to be locked. * @param lockMode Indicates the type of lock to be acquired. Note that read-locks are not valid for this strategy. */ public PessimisticWriteUpdateLockingStrategy(Lockable lockable, LockMode lockMode) { this.lockable = lockable; this.lockMode = lockMode; if ( lockMode.lessThan( LockMode.PESSIMISTIC_READ ) ) { throw new HibernateException( "[" + lockMode + "] not valid for update statement" ); } if ( !lockable.isVersioned() ) { LOG.writeLocksNotSupported( lockable.getEntityName() ); this.sql = null; } else { this.sql = generateLockString(); } }
public InfinispanPessimisticWriteLockingStrategy(Lockable lockable, LockMode lockMode) { this.lockMode = lockMode; this.lockable = lockable; TypeTranslator typeTranslator = lockable.getFactory().getServiceRegistry().getService( TypeTranslator.class ); this.identifierGridType = typeTranslator.getType( lockable.getIdentifierType() ); provider = getProvider( lockable.getFactory() ); }
/** * Construct locking strategy. * * @param lockable The metadata for the entity to be locked. * @param lockMode Indicates the type of lock to be acquired. */ public OptimisticForceIncrementLockingStrategy(Lockable lockable, LockMode lockMode) { this.lockable = lockable; this.lockMode = lockMode; if ( lockMode.lessThan( LockMode.OPTIMISTIC_FORCE_INCREMENT ) ) { throw new HibernateException( "[" + lockMode + "] not valid for [" + lockable.getEntityName() + "]" ); } }
protected String generateLockString() { final SessionFactoryImplementor factory = lockable.getFactory(); final Update update = new Update( factory.getDialect() ); update.setTableName( lockable.getRootTableName() ); update.addPrimaryKeyColumns( lockable.getRootTableIdentifierColumnNames() ); update.setVersionColumnName( lockable.getVersionColumnName() ); update.addColumn( lockable.getVersionColumnName() ); if ( factory.getSessionFactoryOptions().isCommentsEnabled() ) { update.setComment( lockMode + " lock " + lockable.getEntityName() ); } return update.toStatementString(); }
@Override public void lock(Serializable id, Object version, Object object, int timeout, SharedSessionContractImplementor session) { if ( !lockable.isVersioned() ) { throw new HibernateException( "write locks via update not supported for non-versioned entities [" + lockable.getEntityName() + "]" ); final PreparedStatement st = session.getJdbcCoordinator().getStatementPreparer().prepareStatement( sql ); try { lockable.getVersionType().nullSafeSet( st, version, 1, session ); int offset = 2; lockable.getIdentifierType().nullSafeSet( st, id, offset, session ); offset += lockable.getIdentifierType().getColumnSpan( factory ); if ( lockable.isVersioned() ) { lockable.getVersionType().nullSafeSet( st, version, offset, session ); factory.getStatistics().optimisticFailure( lockable.getEntityName() ); throw new StaleObjectStateException( lockable.getEntityName(), id );
@Override public void lock(Serializable id, Object version, Object object, int timeout, SharedSessionContractImplementor session) { if ( !lockable.isVersioned() ) { throw new OptimisticLockException( object, "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" ); } final EntityEntry entry = session.getPersistenceContext().getEntry( object ); // Register the EntityVerifyVersionProcess action to run just prior to transaction commit. ( (EventSource) session ).getActionQueue().registerProcess( new EntityVerifyVersionProcess( object, entry ) ); }
public MapPessimisticWriteLockingStrategy(Lockable lockable, LockMode lockMode) { this.lockable = lockable; this.lockMode = lockMode; TypeTranslator typeTranslator = lockable.getFactory().getServiceRegistry().getService( TypeTranslator.class ); this.identifierGridType = typeTranslator.getType( lockable.getIdentifierType() ); }
if ( lockMode != null ) { final Lockable drivingPersister = ( Lockable ) getEntityPersisters()[i]; final String rootSqlAlias = drivingPersister.getRootTableAlias( drivingSqlAliases[i] ); locks.setAliasSpecificLockMode( rootSqlAlias, lockMode ); if ( keyColumnNames != null ) { keyColumnNames.put( rootSqlAlias, drivingPersister.getRootTableIdentifierColumnNames() );
/** * Construct locking strategy. * * @param lockable The metadata for the entity to be locked. * @param lockMode Indicates the type of lock to be acquired. */ public PessimisticForceIncrementLockingStrategy(Lockable lockable, LockMode lockMode) { this.lockable = lockable; this.lockMode = lockMode; // ForceIncrement can be used for PESSIMISTIC_READ, PESSIMISTIC_WRITE or PESSIMISTIC_FORCE_INCREMENT if ( lockMode.lessThan( LockMode.PESSIMISTIC_READ ) ) { throw new HibernateException( "[" + lockMode + "] not valid for [" + lockable.getEntityName() + "]" ); } }
protected String generateLockString() { final SessionFactoryImplementor factory = lockable.getFactory(); final Update update = new Update( factory.getDialect() ); update.setTableName( lockable.getRootTableName() ); update.addPrimaryKeyColumns( lockable.getRootTableIdentifierColumnNames() ); update.setVersionColumnName( lockable.getVersionColumnName() ); update.addColumn( lockable.getVersionColumnName() ); if ( factory.getSessionFactoryOptions().isCommentsEnabled() ) { update.setComment( lockMode + " lock " + lockable.getEntityName() ); } return update.toStatementString(); }
@Override public void lock(Serializable id, Object version, Object object, int timeout, SharedSessionContractImplementor session) { if ( !lockable.isVersioned() ) { throw new HibernateException( "write locks via update not supported for non-versioned entities [" + lockable.getEntityName() + "]" ); final PreparedStatement st = session.getJdbcCoordinator().getStatementPreparer().prepareStatement( sql ); try { lockable.getVersionType().nullSafeSet( st, version, 1, session ); int offset = 2; lockable.getIdentifierType().nullSafeSet( st, id, offset, session ); offset += lockable.getIdentifierType().getColumnSpan( factory ); if ( lockable.isVersioned() ) { lockable.getVersionType().nullSafeSet( st, version, offset, session ); factory.getStatistics().optimisticFailure( lockable.getEntityName() ); throw new StaleObjectStateException( lockable.getEntityName(), id );
/** * Construct a locking strategy based on SQL UPDATE statements. * * @param lockable The metadata for the entity to be locked. * @param lockMode Indicates the type of lock to be acquired. Note that * read-locks are not valid for this strategy. */ public PessimisticReadUpdateLockingStrategy(Lockable lockable, LockMode lockMode) { this.lockable = lockable; this.lockMode = lockMode; if ( lockMode.lessThan( LockMode.PESSIMISTIC_READ ) ) { throw new HibernateException( "[" + lockMode + "] not valid for update statement" ); } if ( !lockable.isVersioned() ) { LOG.writeLocksNotSupported( lockable.getEntityName() ); this.sql = null; } else { this.sql = generateLockString(); } }
@Override public void lock(Serializable id, Object version, Object object, int timeout, SharedSessionContractImplementor session) throws StaleObjectStateException, LockingStrategyException { TypeTranslator typeTranslator = lockable.getFactory().getServiceRegistry().getService( TypeTranslator.class ); GridType idGridType = typeTranslator.getType( lockable.getIdentifierType() ); EntityKey key = EntityKeyBuilder.fromData( ( (OgmEntityPersister) lockable ).getRootEntityKeyMetadata(), idGridType, id, session ); IgniteCache<Object, BinaryObject> cache = provider.getEntityCache( key.getMetadata() ); Lock lock = cache.lock( provider.createKeyObject( key ) ); try { lock.tryLock( timeout, TimeUnit.MILLISECONDS ); } catch (InterruptedException e) { throw new IgniteLockingStrategyException( object, e.getMessage(), e ); } }
.findFromElementByUserOrSqlAlias( userAlias, drivingSqlAlias ) .getQueryable(); final String sqlAlias = drivingPersister.getRootTableAlias( drivingSqlAlias ); keyColumnNames.put( sqlAlias, drivingPersister.getRootTableIdentifierColumnNames() );