Package org.hibernate

Examples of org.hibernate.LockOptions


      List<AfterLoadAction> afterLoadActions) {
    if ( dialect.useFollowOnLocking() ) {
      LOG.usingFollowOnLocking();
      // currently only one lock mode is allowed in follow-on locking
      final LockMode lockMode = determineFollowOnLockMode( parameters.getLockOptions() );
      final LockOptions lockOptions = new LockOptions( lockMode );
      lockOptions.setTimeOut( parameters.getLockOptions().getTimeOut() );
      lockOptions.setScope( parameters.getLockOptions().getScope() );
      afterLoadActions.add(
          new AfterLoadAction() {
            @Override
            public void afterLoad(SessionImplementor session, Object entity, Loadable persister) {
              ( (Session) session ).buildLockRequest( lockOptions ).lock( persister.getEntityName(), entity );
            }
          }
      );
      parameters.setLockOptions( new LockOptions() );
      return true;
    }
    return false;
  }
View Full Code Here


          st.setFetchSize( selection.getFetchSize() );
        }
      }

      // handle lock timeout...
      LockOptions lockOptions = queryParameters.getLockOptions();
      if ( lockOptions != null ) {
        if ( lockOptions.getTimeOut() != LockOptions.WAIT_FOREVER ) {
          if ( !dialect.supportsLockTimeouts() ) {
            if ( LOG.isDebugEnabled() ) {
              LOG.debugf(
                  "Lock timeout [%s] requested but dialect reported to not support lock timeouts",
                  lockOptions.getTimeOut()
              );
            }
          }
          else if ( dialect.isLockTimeoutParameterized() ) {
            st.setInt( col++, lockOptions.getTimeOut() );
          }
        }
      }

      if ( LOG.isTraceEnabled() )
View Full Code Here

  }

  private class LockRequestImpl implements LockRequest {
    private final LockOptions lockOptions;
    private LockRequestImpl(LockOptions lo) {
      lockOptions = new LockOptions();
      LockOptions.copy(lo, lockOptions);
    }
View Full Code Here

    return event.getResult();
  }

  @Override
  public Object load(Class entityClass, Serializable id, LockMode lockMode) throws HibernateException {
    return this.byId( entityClass ).with( new LockOptions( lockMode ) ).getReference( id );
  }
View Full Code Here

    return this.byId( entityClass ).with( lockOptions ).getReference( id );
  }

  @Override
  public Object load(String entityName, Serializable id, LockMode lockMode) throws HibernateException {
    return this.byId( entityName ).with( new LockOptions( lockMode ) ).getReference( id );
  }
View Full Code Here

    return this.byId( entityName ).with( lockOptions ).getReference( id );
  }

  @Override
  public Object get(Class entityClass, Serializable id, LockMode lockMode) throws HibernateException {
    return this.byId( entityClass ).with( new LockOptions( lockMode ) ).load( id );
  }
View Full Code Here

    return this.byId( entityClass ).with( lockOptions ).load( id );
  }

  @Override
  public Object get(String entityName, Serializable id, LockMode lockMode) throws HibernateException {
    return this.byId( entityName ).with( new LockOptions( lockMode ) ).load( id );
  }
View Full Code Here

        name,
        query,
        cacheable,
        cacheRegion,
        timeout,
        new LockOptions().setTimeOut( lockTimeout ),
        fetchSize,
        flushMode,
        cacheMode,
        readOnly,
        comment,
View Full Code Here

    }
  }

  protected String generateLockString(int lockTimeout) {
    final SessionFactoryImplementor factory = getLockable().getFactory();
    final LockOptions lockOptions = new LockOptions( getLockMode() );
    lockOptions.setTimeOut( lockTimeout );
    final SimpleSelect select = new SimpleSelect( factory.getDialect() )
        .setLockOptions( lockOptions )
        .setTableName( getLockable().getRootTableName() )
        .addColumn( getLockable().getRootTableIdentifierColumnNames()[0] )
        .addCondition( getLockable().getRootTableIdentifierColumnNames(), "=?" );
View Full Code Here

   * @return The table with any required lock hints.
   * @deprecated use {@code appendLockHint(LockOptions,String)} instead
   */
  @Deprecated
  public String appendLockHint(LockMode mode, String tableName) {
    return appendLockHint( new LockOptions( mode ), tableName );
  }
View Full Code Here

TOP

Related Classes of org.hibernate.LockOptions

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.