/** * 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() + "]" ); } }
/** * 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 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() + "]" ); } }
if ( LockMode.READ.lessThan( lockMode ) ) { upgradeType = lockMode; this.lockMode = lockMode; final Map.Entry me = ( Map.Entry ) iter.next(); final LockMode lockMode = ( LockMode ) me.getValue(); if ( LockMode.READ.lessThan( lockMode ) ) { final String tableAlias = ( String ) me.getKey(); if ( dialect.forUpdateOfColumns() ) {
/** * 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(); } }
/** * 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(); } }
/** * 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(); } }
/** * Attempts to load the entity from the second-level cache. * * @param event The load event * @param persister The persister for the entity being requested for load * * @return The entity from the second-level cache, or null. */ public Object loadFromSecondLevelCache( final LoadEvent event, final EntityPersister persister, final EntityKey entityKey) { final SessionImplementor source = event.getSession(); final boolean useCache = persister.canReadFromCache() && source.getCacheMode().isGetEnabled() && event.getLockMode().lessThan( LockMode.READ ); if ( !useCache ) { // we can't use cache here return null; } final Object ce = getFromSharedCache( event, persister, source ); if ( ce == null ) { // nothing was found in cache return null; } return processCachedEntry( event, persister, ce, source, entityKey ); }
if ( entry.getLockMode().lessThan( requestedLockMode ) ) {
private void checkVersion( ResultSet resultSet, ResultSetProcessingContext context, EntityKey entityKey, Object existing) { final LockMode requestedLockMode = context.resolveLockMode( entityReference ); if ( requestedLockMode != LockMode.NONE ) { final LockMode currentLockMode = context.getSession().getPersistenceContext().getEntry( existing ).getLockMode(); final boolean isVersionCheckNeeded = entityReference.getEntityPersister().isVersioned() && currentLockMode.lessThan( requestedLockMode ); // we don't need to worry about existing version being uninitialized because this block isn't called // by a re-entrant load (re-entrant loads *always* have lock mode NONE) if ( isVersionCheckNeeded ) { //we only check the version when *upgrading* lock modes checkVersion( context.getSession(), resultSet, entityReference.getEntityPersister(), entityReferenceAliases.getColumnAliases(), entityKey, existing ); //we need to upgrade the lock mode to the mode requested context.getSession().getPersistenceContext().getEntry( existing ).setLockMode( requestedLockMode ); } } }
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.warn("write locks via update not supported for non-versioned entities [" + lockable.getEntityName() + "]"); this.sql = null; } else { this.sql = generateLockString(); } }
/** * 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() + "]" ); } }
/** * 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() + "]" ); } }
/** * 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 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 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() + "]" ); } }
/** * 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 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() + "]" ); } }
/** * 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() + "]" ); } }
/** * 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() + "]" ); } }