Package javax.persistence

Examples of javax.persistence.OptimisticLockException


        }
        else if (jdoe instanceof JDOOptimisticVerificationException)
        {
            if (jdoe.getNestedExceptions() != null)
            {
                return new OptimisticLockException(jdoe.getMessage(), jdoe.getCause());
            }
            else
            {
                return new OptimisticLockException(jdoe.getMessage(), jdoe);
            }
        }
        else
        {
            // JPA doesnt have "internal" exceptions so just give a PersistenceException
View Full Code Here


        }
        else if (jpe instanceof JPOXOptimisticException)
        {
            if (jpe.getNestedExceptions() != null)
            {
                return new OptimisticLockException(jpe.getMessage(), jpe.getCause());
            }
            else
            {
                return new OptimisticLockException(jpe.getMessage(), jpe);
            }
        }
        else
        {
            // JPA doesnt have "internal" exceptions so just give a PersistenceException
View Full Code Here

      {
         equal = oldVersion.equals(version);
      }
      if ( !equal )
      {
         throw new OptimisticLockException("current database version number does not match passivated version number");
      }
   }
View Full Code Here

      {
         equal = oldVersion.equals(version);
      }
      if (!equal)
      {
         throw new OptimisticLockException("Current database version number does not match passivated version number");
      }
   }
View Full Code Here

  public PersistenceException wrapLockException(HibernateException e, LockOptions lockOptions) {
    PersistenceException pe;
    if ( e instanceof org.hibernate.OptimisticLockException ) {
      org.hibernate.OptimisticLockException ole = ( org.hibernate.OptimisticLockException ) e;
      pe = new OptimisticLockException( ole.getMessage(), ole, ole.getEntity() );
    }
    else if ( e instanceof org.hibernate.PessimisticLockException ) {
      org.hibernate.PessimisticLockException ple = ( org.hibernate.PessimisticLockException ) e;
      if ( lockOptions != null && lockOptions.getTimeOut() > -1 ) {
        // assume lock timeout occurred if a timeout or NO WAIT was specified
        pe = new LockTimeoutException( ple.getMessage(), ple, ple.getEntity() );
      }
      else {
        pe = new PessimisticLockException( ple.getMessage(), ple, ple.getEntity() );
      }
    }
    else {
      pe = new OptimisticLockException( e );
    }
    return pe;
  }
View Full Code Here

      Serializable identifier = sose.getIdentifier();
      if ( identifier != null ) {
        Object entity = session.load( sose.getEntityName(), identifier );
        if ( entity instanceof Serializable ) {
          //avoid some user errors regarding boundary crossing
          pe = new OptimisticLockException( null, e, entity );
        }
        else {
          pe = new OptimisticLockException( e );
        }
      }
      else {
        pe = new OptimisticLockException( e );
      }
    }
    else {
      pe = new OptimisticLockException( e );
    }
    return pe;
  }
View Full Code Here

      persistRequest.postExecute();
    } catch (OptimisticLockException e) {
      // add the SQL and bind values to error message
      String m = e.getMessage() + " sql[" + sql + "] bind[" + bindLog + "]";
      persistRequest.getTransaction().logSummary("OptimisticLockException:" + m);
      throw new OptimisticLockException(m, null, e.getEntity());
    }
  }
View Full Code Here

        String msg = "Error invoking Oracle sendBatch method via reflection";
      throw new PersistenceException(msg, e);
    }
    if (occCheck && rows != expectedRows) {
        String msg = "Batch execution expected "+expectedRows+" but got "+rows+"  sql:"+sql;
      throw new OptimisticLockException(msg);
    }
   
    return rows;
  }
View Full Code Here

      if ( identifier != null ) {
        try {
          Object entity = internalGetSession().load( sose.getEntityName(), identifier );
          if ( entity instanceof Serializable ) {
            //avoid some user errors regarding boundary crossing
            pe = new OptimisticLockException( null, e, entity );
          }
          else {
            pe = new OptimisticLockException( e );
          }
        }
        catch ( EntityNotFoundException enfe ) {
          pe = new OptimisticLockException( e );
        }
      }
      else {
        pe = new OptimisticLockException( e );
      }
    }
    else {
      pe = new OptimisticLockException( e );
    }
    return pe;
  }
View Full Code Here

  public PersistenceException wrapLockException(HibernateException e, LockOptions lockOptions) {
    final PersistenceException pe;
    if ( e instanceof OptimisticEntityLockException ) {
      final OptimisticEntityLockException lockException = (OptimisticEntityLockException) e;
      pe = new OptimisticLockException( lockException.getMessage(), lockException, lockException.getEntity() );
    }
    else if ( e instanceof org.hibernate.exception.LockTimeoutException ) {
      pe = new LockTimeoutException( e.getMessage(), e, null );
    }
    else if ( e instanceof PessimisticEntityLockException ) {
      PessimisticEntityLockException lockException = (PessimisticEntityLockException) e;
      if ( lockOptions != null && lockOptions.getTimeOut() > -1 ) {
        // assume lock timeout occurred if a timeout or NO WAIT was specified
        pe = new LockTimeoutException( lockException.getMessage(), lockException, lockException.getEntity() );
      }
      else {
        pe = new PessimisticLockException( lockException.getMessage(), lockException, lockException.getEntity() );
      }
    }
    else if ( e instanceof org.hibernate.PessimisticLockException ) {
      org.hibernate.PessimisticLockException jdbcLockException = ( org.hibernate.PessimisticLockException ) e;
      if ( lockOptions != null && lockOptions.getTimeOut() > -1 ) {
        // assume lock timeout occurred if a timeout or NO WAIT was specified
        pe = new LockTimeoutException( jdbcLockException.getMessage(), jdbcLockException, null );
      }
      else {
        pe = new PessimisticLockException( jdbcLockException.getMessage(), jdbcLockException, null );
      }
    }
    else {
      pe = new OptimisticLockException( e );
    }
    return pe;
  }
View Full Code Here

TOP

Related Classes of javax.persistence.OptimisticLockException

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.