Package org.hibernate.exception

Examples of org.hibernate.exception.LockAcquisitionException


      // expected
      assertEquals(sgex, ex.getCause());
      assertTrue(ex.getMessage().contains("mymsg"));
    }

    final LockAcquisitionException laex = new LockAcquisitionException("mymsg", sqlEx);
    try {
      hibernateTemplate.execute(new HibernateCallback<Object>() {
        @Override
        public Object doInHibernate(Session session)  {
          throw laex;
View Full Code Here


    if (ex instanceof QueryTimeoutException) {
      QueryTimeoutException jdbcEx = (QueryTimeoutException) ex;
      return new org.springframework.dao.QueryTimeoutException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]", ex);
    }
    if (ex instanceof LockAcquisitionException) {
      LockAcquisitionException jdbcEx = (LockAcquisitionException) ex;
      return new CannotAcquireLockException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]", ex);
    }
    if (ex instanceof PessimisticLockException) {
      PessimisticLockException jdbcEx = (PessimisticLockException) ex;
      return new PessimisticLockingFailureException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]", ex);
    }
    if (ex instanceof ConstraintViolationException) {
      ConstraintViolationException jdbcEx = (ConstraintViolationException) ex;
      return new DataIntegrityViolationException(ex.getMessage()  + "; SQL [" + jdbcEx.getSQL() +
          "]; constraint [" + jdbcEx.getConstraintName() + "]", ex);
    }
    if (ex instanceof DataException) {
      DataException jdbcEx = (DataException) ex;
      return new DataIntegrityViolationException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]", ex);
    }
    // end of JDBCException subclass handling

    if (ex instanceof QueryException) {
      return new InvalidDataAccessResourceUsageException(ex.getMessage(), ex);
View Full Code Here

    if (ex instanceof QueryTimeoutException) {
      QueryTimeoutException jdbcEx = (QueryTimeoutException) ex;
      return new org.springframework.dao.QueryTimeoutException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]", ex);
    }
    if (ex instanceof LockAcquisitionException) {
      LockAcquisitionException jdbcEx = (LockAcquisitionException) ex;
      return new CannotAcquireLockException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]", ex);
    }
    if (ex instanceof PessimisticLockException) {
      PessimisticLockException jdbcEx = (PessimisticLockException) ex;
      return new PessimisticLockingFailureException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]", ex);
    }
    if (ex instanceof ConstraintViolationException) {
      ConstraintViolationException jdbcEx = (ConstraintViolationException) ex;
      return new DataIntegrityViolationException(ex.getMessage()  + "; SQL [" + jdbcEx.getSQL() +
          "]; constraint [" + jdbcEx.getConstraintName() + "]", ex);
    }
    if (ex instanceof DataException) {
      DataException jdbcEx = (DataException) ex;
      return new DataIntegrityViolationException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]", ex);
    }
    if (ex instanceof JDBCException) {
      return new HibernateJdbcException((JDBCException) ex);
    }
    // end of JDBCException (subclass) handling
View Full Code Here

      // expected
      assertEquals(sgex, ex.getCause());
      assertTrue(ex.getMessage().indexOf("mymsg") != -1);
    }

    final LockAcquisitionException laex = new LockAcquisitionException("mymsg", sqlEx);
    try {
      hibernateTemplate.execute(new HibernateCallback<Object>() {
        @Override
        public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
          throw laex;
View Full Code Here

        // deadlocks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        if ( 60 == errorCode ) {
          // ORA-00060: deadlock detected while waiting for resource
          return new LockAcquisitionException( message, sqlException, sql );
        }
        else if ( 4020 == errorCode ) {
          // ORA-04020 deadlock detected while trying to lock object
          return new LockAcquisitionException( message, sqlException, sql );
        }


        // query cancelled ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
View Full Code Here

      @Override
      public JDBCException convert(SQLException sqlException, String message, String sql) {
        final String sqlState = JdbcExceptionHelper.extractSqlState( sqlException );

        if ( "40P01".equals( sqlState ) ) { // DEADLOCK DETECTED
          return new LockAcquisitionException( message, sqlException, sql );
        }

        if ( "55P03".equals( sqlState ) ) { // LOCK NOT AVAILABLE
          return new PessimisticLockException( message, sqlException, sql );
        }
View Full Code Here

      @Override
      public JDBCException convert(SQLException sqlException, String message, String sql) {
        final String sqlState = JdbcExceptionHelper.extractSqlState( sqlException );

        if ( "40P01".equals( sqlState ) ) { // DEADLOCK DETECTED
          return new LockAcquisitionException( message, sqlException, sql );
        }

        if ( "55P03".equals( sqlState ) ) { // LOCK NOT AVAILABLE
          return new PessimisticLockException( message, sqlException, sql );
        }
View Full Code Here

                    JDBCException exception = null;

                    int errorCode = JdbcExceptionHelper.extractErrorCode(sqlException);

                    if (40001 == errorCode) { // DEADLOCK DETECTED
                        exception = new LockAcquisitionException(message, sqlException, sql);
                    }

                    if (50200 == errorCode) { // LOCK NOT AVAILABLE
                        exception = new PessimisticLockException(message, sqlException, sql);
                    }
View Full Code Here

   @RetryTransaction(7)
   public void retryFive() {
      logger.info("retryFive:: start");
      counter++;
      if (counter < 5) {
         throw new LockAcquisitionException("sample dal exception",
               new SQLException("1111"));
      }
   }
View Full Code Here

   @Override
   @Transactional
   @RetryTransaction(10)
   public void retryForever() {
      logger.info("retryForever:: start");
      throw new LockAcquisitionException("sample dal exception",
            new SQLException("1111"));
   }
View Full Code Here

TOP

Related Classes of org.hibernate.exception.LockAcquisitionException

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.