Package org.hibernate

Examples of org.hibernate.LockMode


  }

  private static NativeSQLQueryJoinReturn bindReturnJoin(Element returnElem, Mappings mappings) {
    String alias = returnElem.attributeValue( "alias" );
    String roleAttribute = returnElem.attributeValue( "property" );
    LockMode lockMode = getLockMode( returnElem.attributeValue( "lock-mode" ) );
    int dot = roleAttribute.lastIndexOf( '.' );
    if ( dot == -1 ) {
      throw new MappingException(
          "Role attribute for sql query return [alias=" + alias +
          "] not formatted correctly {owningAlias.propertyName}"
View Full Code Here


  }

  private static NativeSQLQueryCollectionReturn bindLoadCollection(Element returnElem, Mappings mappings) {
    String alias = returnElem.attributeValue( "alias" );
    String collectionAttribute = returnElem.attributeValue( "role" );
    LockMode lockMode = getLockMode( returnElem.attributeValue( "lock-mode" ) );
    int dot = collectionAttribute.lastIndexOf( '.' );
    if ( dot == -1 ) {
      throw new MappingException(
          "Collection attribute for sql query return [alias=" + alias +
          "] not formatted correctly {OwnerClassName.propertyName}"
View Full Code Here

    return getForUpdateString() + " of " + aliases;
  }

  @Override
  public String getForUpdateString(final String aliases, final LockOptions lockOptions) {
    LockMode lockMode = lockOptions.getLockMode();
    final 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;
      }
    }

    // not sure why this is sometimes empty
View Full Code Here

    return '[';
  }

  @Override
  public String appendLockHint(LockOptions lockOptions, String tableName) {
    final LockMode mode = lockOptions.getLockMode();
    switch ( mode ) {
      case UPGRADE:
      case UPGRADE_NOWAIT:
      case PESSIMISTIC_WRITE:
      case WRITE:
View Full Code Here

    final EntityEntry entry = event.getSession().getPersistenceContext().getEntry( entity );
    if ( entry == null ) {
      throw new AssertionFailure( "possible non-threadsafe access to the session" );
    }

    final LockMode lockMode = entry.getLockMode();
    if ( LockMode.PESSIMISTIC_FORCE_INCREMENT.equals( lockMode ) ) {
      final EntityPersister persister = entry.getPersister();
      final Object nextVersion = persister.forceVersionIncrement(
          entry.getId(),
          entry.getVersion(),
View Full Code Here

    final Iterator itr = aliasedLockOptions.getAliasLockIterator();
    final StringBuilder buffer = new StringBuilder( sql );
    int correction = 0;
    while ( itr.hasNext() ) {
      final Map.Entry entry = (Map.Entry) itr.next();
      final LockMode lockMode = (LockMode) entry.getValue();
      if ( lockMode.greaterThan( LockMode.READ ) ) {
        final String alias = (String) entry.getKey();
        int start = -1;
        int end = -1;
        if ( sql.endsWith( " " + alias ) ) {
          start = ( sql.length() - alias.length() ) + correction;
View Full Code Here

    // NOTE : since SQLServer2005 the nowait hint is supported
    if ( lockOptions.getLockMode() == LockMode.UPGRADE_NOWAIT ) {
      return tableName + " with (updlock, rowlock, nowait)";
    }

    final LockMode mode = lockOptions.getLockMode();
    final boolean isNoWait = lockOptions.getTimeOut() == LockOptions.NO_WAIT;
    final String noWaitStr = isNoWait ? ", nowait" : "";
    switch ( mode ) {
      case UPGRADE_NOWAIT:
        return tableName + " with (updlock, rowlock, nowait)";
View Full Code Here

   *
   * @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() );
  }
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", "UnusedParameters"})
  public String getForUpdateString(String aliases, LockOptions lockOptions) {
    LockMode lockMode = lockOptions.getLockMode();
    final 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

   * @param lockOptions contains the requested lock mode.
   * @param source The session which is the source of the event being processed.
   */
  protected void upgradeLock(Object object, EntityEntry entry, LockOptions lockOptions, EventSource source) {

    LockMode requestedLockMode = lockOptions.getLockMode();
    if ( requestedLockMode.greaterThan( entry.getLockMode() ) ) {
      // The user requested a "greater" (i.e. more restrictive) form of
      // pessimistic lock

      if ( entry.getStatus() != Status.MANAGED ) {
        throw new ObjectDeletedException(
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.