@Override public int getTimeOut() { return lockOptions.getTimeOut(); }
public int getLockTimeout() { return this.lockOptions.getTimeOut(); }
public int getLockTimeout() { return this.lockOptions.getTimeOut(); }
public int getLockTimeout() { return this.lockOptions.getTimeOut(); }
@Override public String appendLockHint(LockOptions lockOptions, String tableName) { LockMode lockMode = lockOptions.getAliasSpecificLockMode( tableName ); if(lockMode == null) { lockMode = lockOptions.getLockMode(); } final String writeLockStr = lockOptions.getTimeOut() == LockOptions.SKIP_LOCKED ? "updlock" : "updlock, holdlock"; final String readLockStr = lockOptions.getTimeOut() == LockOptions.SKIP_LOCKED ? "updlock" : "holdlock"; final String noWaitStr = lockOptions.getTimeOut() == LockOptions.NO_WAIT ? ", nowait" : ""; final String skipLockStr = lockOptions.getTimeOut() == LockOptions.SKIP_LOCKED ? ", readpast" : ""; switch ( lockMode ) { case UPGRADE: case PESSIMISTIC_WRITE: case WRITE: { return tableName + " with (" + writeLockStr + ", rowlock" + noWaitStr + skipLockStr + ")"; } case PESSIMISTIC_READ: { return tableName + " with (" + readLockStr + ", rowlock" + noWaitStr + skipLockStr + ")"; } case UPGRADE_SKIPLOCKED: return tableName + " with (updlock, rowlock, readpast" + noWaitStr + ")"; case UPGRADE_NOWAIT: return tableName + " with (updlock, holdlock, rowlock, nowait)"; default: { return tableName; } } }
public void setLockTimeout(int timeout) { if ( timeout != lockOptions.getTimeOut() ) { writingOnLockOptions(); this.lockOptions.setTimeOut( timeout ); } }
/** * Given LockOptions (lockMode, timeout), determine the appropriate for update fragment to use. * * @param lockOptions contains the lock mode to apply. * @return The appropriate for update fragment. */ public String getForUpdateString(LockOptions lockOptions) { final LockMode lockMode = lockOptions.getLockMode(); return getForUpdateString( lockMode, lockOptions.getTimeOut() ); }
@Override public String getForUpdateString(final String aliases, final LockOptions lockOptions) { LockMode lockMode = lockOptions.findGreatestLockMode(); lockOptions.setLockMode( lockMode ); // not sure why this is sometimes empty if ( aliases == null || aliases.isEmpty() ) { return getForUpdateString( lockOptions ); } return getForUpdateString( aliases, lockMode, lockOptions.getTimeOut() ); }
@Override public Session.LockRequest lockRequest(LockOptions lockOptions) { int timeout = lockOptions.getTimeOut(); if (timeout > MAX_TIMEOUT) { lockOptions.setTimeOut(MAX_TIMEOUT); } LOG.debug("Build lock request with options {}", lockOptions); return getSession().buildLockRequest(lockOptions); }
public void lock( Serializable id, Object version, Object object, LockOptions lockOptions, SharedSessionContractImplementor session) throws HibernateException { getLocker( lockOptions.getLockMode() ).lock( id, version, object, lockOptions.getTimeOut(), session ); }
/** * Perform a shallow copy. * * @param source Source for the copy (copied from) * @param destination Destination for the copy (copied to) * * @return destination */ public static LockOptions copy(LockOptions source, LockOptions destination) { destination.setLockMode( source.getLockMode() ); destination.setScope( source.getScope() ); destination.setTimeOut( source.getTimeOut() ); if ( source.aliasSpecificLockModes != null ) { destination.aliasSpecificLockModes = new HashMap<String,LockMode>( source.aliasSpecificLockModes ); } destination.setFollowOnLocking( source.getFollowOnLocking() ); return destination; } }
@Override @SuppressWarnings("unchecked") public QueryImplementor setLockOptions(LockOptions lockOptions) { this.lockOptions.setLockMode( lockOptions.getLockMode() ); this.lockOptions.setScope( lockOptions.getScope() ); this.lockOptions.setTimeOut( lockOptions.getTimeOut() ); this.lockOptions.setFollowOnLocking( lockOptions.getFollowOnLocking() ); return this; }
LockOptions locks = new LockOptions(); locks.setLockMode( lockOptions.getLockMode() ); locks.setTimeOut( lockOptions.getTimeOut() ); locks.setScope( lockOptions.getScope() ); Iterator iter = lockOptions.getAliasLockIterator();
/** * Helper to avoid creating many new instances of LoadEvent: it's an allocation hot spot. */ private LoadEvent recycleEventInstance(final LoadEvent event, final Serializable id, final String entityName) { if ( event == null ) { return new LoadEvent( id, entityName, true, this ); } else { event.setEntityClassName( entityName ); event.setEntityId( id ); event.setInstanceToLoad( null ); event.setLockMode( LoadEvent.DEFAULT_LOCK_MODE ); event.setLockScope( LoadEvent.DEFAULT_LOCK_OPTIONS.getScope() ); event.setLockTimeout( LoadEvent.DEFAULT_LOCK_OPTIONS.getTimeOut() ); return event; } }
public EntityLoader( OuterJoinLoadable persister, String[] uniqueKey, Type uniqueKeyType, int batchSize, LockOptions lockOptions, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) throws MappingException { super( persister, uniqueKeyType, factory, loadQueryInfluencers ); EntityJoinWalker walker = new EntityJoinWalker( persister, uniqueKey, batchSize, lockOptions, factory, loadQueryInfluencers ); initFromWalker( walker ); this.compositeKeyManyToOneTargetIndices = walker.getCompositeKeyManyToOneTargetIndices(); postInstantiate(); batchLoader = batchSize > 1; if ( LOG.isDebugEnabled() ) { LOG.debugf( "Static select for entity %s [%s:%s]: %s", entityName, lockOptions.getLockMode(), lockOptions.getTimeOut(), getSQLString() ); } }
@Override public void cascade( EventSource session, Object child, String entityName, Object anything, boolean isCascadeDeleteEnabled) { LOG.tracev( "Cascading to lock: {0}", entityName ); LockMode lockMode = LockMode.NONE; LockOptions lr = new LockOptions(); if ( anything instanceof LockOptions ) { LockOptions lockOptions = (LockOptions) anything; lr.setTimeOut( lockOptions.getTimeOut() ); lr.setScope( lockOptions.getScope() ); lr.setFollowOnLocking( lockOptions.getFollowOnLocking() ); if ( lockOptions.getScope() ) { lockMode = lockOptions.getLockMode(); } } lr.setLockMode( lockMode ); session.buildLockRequest( lr ).lock( entityName, child ); }
@Override public void load(Object object, Serializable id) throws HibernateException { LoadEvent event = loadEvent; loadEvent = null; if ( event == null ) { event = new LoadEvent( id, object, this ); } else { event.setEntityClassName( null ); event.setEntityId( id ); event.setInstanceToLoad( object ); event.setLockMode( LoadEvent.DEFAULT_LOCK_MODE ); event.setLockScope( LoadEvent.DEFAULT_LOCK_OPTIONS.getScope() ); event.setLockTimeout( LoadEvent.DEFAULT_LOCK_OPTIONS.getTimeOut() ); } fireLoad( event, LoadEventListener.RELOAD ); if ( loadEvent == null ) { event.setEntityClassName( null ); event.setEntityId( null ); event.setInstanceToLoad( null ); event.setResult( null ); loadEvent = event; } }
LOG.usingFollowOnLocking(); lockOptions.setTimeOut( parameters.getLockOptions().getTimeOut() ); lockOptions.setScope( parameters.getLockOptions().getScope() ); afterLoadActions.add(
private EntityLoader( SessionFactoryImplementor factory, OuterJoinLoadable persister, String[] uniqueKeyColumnNames, Type uniqueKeyType, QueryBuildingParameters buildingParameters) throws MappingException { super( persister, factory, uniqueKeyColumnNames, uniqueKeyType, buildingParameters ); if ( log.isDebugEnabled() ) { if ( buildingParameters.getLockOptions() != null ) { log.debugf( "Static select for entity %s [%s:%s]: %s", getEntityName(), buildingParameters.getLockOptions().getLockMode(), buildingParameters.getLockOptions().getTimeOut(), getStaticLoadQuery().getSqlStatement() ); } else if ( buildingParameters.getLockMode() != null ) { log.debugf( "Static select for entity %s [%s]: %s", getEntityName(), buildingParameters.getLockMode(), getStaticLoadQuery().getSqlStatement() ); } } }
private EntityLoader( SessionFactoryImplementor factory, OuterJoinLoadable persister, EntityLoader entityLoaderTemplate, Type uniqueKeyType, QueryBuildingParameters buildingParameters) throws MappingException { super( persister, factory, entityLoaderTemplate.getStaticLoadQuery(), uniqueKeyType, buildingParameters ); if ( log.isDebugEnabled() ) { if ( buildingParameters.getLockOptions() != null ) { log.debugf( "Static select for entity %s [%s:%s]: %s", getEntityName(), buildingParameters.getLockOptions().getLockMode(), buildingParameters.getLockOptions().getTimeOut(), getStaticLoadQuery().getSqlStatement() ); } else if ( buildingParameters.getLockMode() != null ) { log.debugf( "Static select for entity %s [%s]: %s", getEntityName(), buildingParameters.getLockMode(), getStaticLoadQuery().getSqlStatement() ); } } }