Package org.hibernate

Examples of org.hibernate.LockMode


            me.getValue() );
      }
    }
    LockMode[] lockModeArray = new LockMode[names.length];
    for ( int i = 0; i < names.length; i++ ) {
      LockMode lm = ( LockMode ) nameLockModes.get( names[i] );
      if ( lm == null ) lm = LockMode.NONE;
      lockModeArray[i] = lm;
    }
    return lockModeArray;
  }
View Full Code Here


    this.dialect = dialect;
  }

  public ForUpdateFragment(Dialect dialect, LockOptions lockOptions, Map<String, String[]> keyColumnNames) throws QueryException {
    this( dialect );
    LockMode upgradeType = null;
    Iterator iter = lockOptions.getAliasLockIterator();
    this.lockOptions =  lockOptions;

    if ( !iter.hasNext()) {  // no tables referenced
      final LockMode lockMode = lockOptions.getLockMode();
      if ( LockMode.READ.lessThan( lockMode ) ) {
        upgradeType = lockMode;
        this.lockMode = lockMode;
      }
    }

    while ( iter.hasNext() ) {
      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() ) {
          String[] keyColumns = keyColumnNames.get( tableAlias ); //use the id column alias
          if ( keyColumns == null ) {
View Full Code Here

   *
   * @param lockOptions contains the lock mode to apply.
   * @return The appropriate for update fragment.
   */
  public String getForUpdateString(LockOptions lockOptions) {
        LockMode lockMode = lockOptions.getLockMode();
        return getForUpdateString( lockMode, lockOptions.getTimeOut() );
  }
View Full Code Here

   * @param lockOptions the lock options to apply
   * @return The appropriate <tt>FOR UPDATE OF column_list</tt> clause string.
   */
  @SuppressWarnings( {"unchecked"})
  public String getForUpdateString(String aliases, LockOptions lockOptions) {
    LockMode lockMode = lockOptions.getLockMode();
    Iterator<Map.Entry<String, LockMode>> itr = lockOptions.getAliasLockIterator();
    while ( itr.hasNext() ) {
      // seek the highest lock mode
      final Map.Entry<String, LockMode>entry = itr.next();
      final LockMode lm = entry.getValue();
      if ( lm.greaterThan(lockMode) ) {
        lockMode = lm;
      }
    }
    lockOptions.setLockMode( lockMode );
    return getForUpdateString( lockOptions );
View Full Code Here

    else if ( LockModeType.class.isInstance( value ) ) {
      return getLockMode( (LockModeType) value );
    }
    else if ( String.class.isInstance( value ) ) {
      // first try LockMode name
      LockMode lockMode = LockMode.valueOf( (String) value );
      if ( lockMode == null ) {
        try {
          lockMode = getLockMode( LockModeType.valueOf( (String) value ) );
        }
        catch ( Exception ignore ) {
View Full Code Here

      QueryParameters parameters,
      Dialect dialect,
      List<AfterLoadAction> afterLoadActions) {
    if ( dialect.useFollowOnLocking() ) {
      // currently only one lock mode is allowed in follow-on locking
      final LockMode lockMode = determineFollowOnLockMode( parameters.getLockOptions() );
      final LockOptions lockOptions = new LockOptions( lockMode );
      if ( lockOptions.getLockMode() != LockMode.UPGRADE_SKIPLOCKED ) {
        LOG.usingFollowOnLocking();
        lockOptions.setTimeOut( parameters.getLockOptions().getTimeOut() );
        lockOptions.setScope( parameters.getLockOptions().getScope() );
View Full Code Here

    }
    return false;
  }

  protected LockMode determineFollowOnLockMode(LockOptions lockOptions) {
    final LockMode lockModeToUse = lockOptions.findGreatestLockMode();

    if ( lockOptions.hasAliasSpecificLockModes() ) {
      LOG.aliasSpecificLockingWithFollowOnLocking( lockModeToUse );
    }
View Full Code Here

    //need to hydrate it.

    // grab its state from the ResultSet and keep it in the Session
    // (but don't yet initialize the object itself)
    // note that we acquire LockMode.READ even if it was not requested
    LockMode acquiredLockMode = lockMode == LockMode.NONE ? LockMode.READ : lockMode;
    loadFromResultSet(
        rs,
        i,
        object,
        instanceClass,
View Full Code Here

    final List<Object> values = new ArrayList<Object>();
    final List<Type> types = new ArrayList<Type>();
    final Iterator<CriteriaImpl.Subcriteria> subcriteriaIterator = rootCriteria.iterateSubcriteria();
    while ( subcriteriaIterator.hasNext() ) {
      final CriteriaImpl.Subcriteria subcriteria = subcriteriaIterator.next();
      final LockMode lm = subcriteria.getLockMode();
      if ( lm != null ) {
        lockOptions.setAliasSpecificLockMode( getSQLAlias( subcriteria ), lm );
      }
      if ( subcriteria.getWithClause() != null ) {
        final TypedValue[] tv = subcriteria.getWithClause().getTypedValues( subcriteria, this );
View Full Code Here

    // need to hydrate it.
    // grab its state from the ResultSet and keep it in the Session
    // (but don't yet initialize the object itself)
    // note that we acquire LockMode.READ even if it was not requested
    log.trace( "hydrating entity state" );
    final LockMode requestedLockMode = context.resolveLockMode( entityReference );
    final LockMode lockModeToAcquire = requestedLockMode == LockMode.NONE
        ? LockMode.READ
        : requestedLockMode;

    loadFromResultSet(
        resultSet,
View Full Code Here

TOP

Related Classes of org.hibernate.LockMode

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.