Package org.hibernate

Examples of org.hibernate.JDBCException


      fail("INSERT should have failed");
    }
    catch(SQLException sqle) {
      JDBCExceptionReporter.logExceptions(sqle, "Just output!!!!");
      JDBCException jdbcException = converter.convert(sqle, null, null);
      assertEquals( "Bad conversion [" + sqle.getMessage() + "]", ConstraintViolationException.class , jdbcException.getClass() );
      ConstraintViolationException ex = (ConstraintViolationException) jdbcException;
      System.out.println("Violated constraint name: " + ex.getConstraintName());
    }
    finally {
      if ( ps != null ) {
View Full Code Here


   * @see SessionFactoryUtils#convertHibernateAccessException
   * @see #setJdbcExceptionTranslator
   */
  protected DataAccessException convertHibernateAccessException(HibernateException ex) {
    if (this.jdbcExceptionTranslator != null && ex instanceof JDBCException) {
      JDBCException jdbcEx = (JDBCException) ex;
      return this.jdbcExceptionTranslator.translate(
          "Hibernate operation: " + jdbcEx.getMessage(), jdbcEx.getSQL(), jdbcEx.getSQLException());
    }
    return SessionFactoryUtils.convertHibernateAccessException(ex);
  }
View Full Code Here

          SessionFactoryUtils.logger.debug("Flushing Hibernate Session on transaction synchronization");
          session.flush();
        }
        catch (HibernateException ex) {
          if (this.jdbcExceptionTranslator != null && ex instanceof JDBCException) {
            JDBCException jdbcEx = (JDBCException) ex;
            throw this.jdbcExceptionTranslator.translate(
                "Hibernate flushing: " + jdbcEx.getMessage(), jdbcEx.getSQL(), jdbcEx.getSQLException());
          }
          throw SessionFactoryUtils.convertHibernateAccessException(ex);
        }
      }
    }
View Full Code Here

   * @see SessionFactoryUtils#convertHibernateAccessException
   * @see #setJdbcExceptionTranslator
   */
  protected DataAccessException convertHibernateAccessException(HibernateException ex) {
    if (this.jdbcExceptionTranslator != null && ex instanceof JDBCException) {
      JDBCException jdbcEx = (JDBCException) ex;
      return this.jdbcExceptionTranslator.translate(
          "Hibernate operation: " + jdbcEx.getMessage(), jdbcEx.getSQL(), jdbcEx.getSQLException());
    }
    return SessionFactoryUtils.convertHibernateAccessException(ex);
  }
View Full Code Here

   * @see SessionFactoryUtils#convertHibernateAccessException
   * @see #setJdbcExceptionTranslator
   */
  protected DataAccessException convertHibernateAccessException(HibernateException ex) {
    if (this.jdbcExceptionTranslator != null && ex instanceof JDBCException) {
      JDBCException jdbcEx = (JDBCException) ex;
      return this.jdbcExceptionTranslator.translate(
          "Hibernate operation: " + jdbcEx.getMessage(), jdbcEx.getSQL(), jdbcEx.getSQLException());
    }
    return SessionFactoryUtils.convertHibernateAccessException(ex);
  }
View Full Code Here

          SessionFactoryUtils.logger.debug("Flushing Hibernate Session on transaction synchronization");
          session.flush();
        }
        catch (HibernateException ex) {
          if (this.jdbcExceptionTranslator != null && ex instanceof JDBCException) {
            JDBCException jdbcEx = (JDBCException) ex;
            throw this.jdbcExceptionTranslator.translate(
                "Hibernate flushing: " + jdbcEx.getMessage(), jdbcEx.getSQL(), jdbcEx.getSQLException());
          }
          throw SessionFactoryUtils.convertHibernateAccessException(ex);
        }
      }
    }
View Full Code Here

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

    final JDBCException jdex = new JDBCException("mymsg", sqlEx);
    try {
      createTemplate().execute(new HibernateCallback() {
        public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
          throw jdex;
        }
View Full Code Here

    if (delegate == null) {
      delegate = new SQLExceptionConversionDelegate() {

        @Override
        public JDBCException convert(SQLException sqlException, String message, String sql) {
                    JDBCException exception = null;

                    int errorCode = JdbcExceptionHelper.extractErrorCode(sqlException);

                    if (40001 == errorCode) { // DEADLOCK DETECTED
                        exception = new LockAcquisitionException(message, sqlException, sql);
View Full Code Here

        st.close();
      }

    }
    catch ( SQLException sqle ) {
      JDBCException e = session.getFactory().getSQLExceptionHelper().convert(
          sqle,
          "could not lock: " + MessageHelper.infoString( getLockable(), id, session.getFactory() ),
          sql
      );
      throw new PessimisticLockException( "could not obtain pessimistic lock", e, object );
View Full Code Here

        st.close();
      }

    }
    catch ( SQLException sqle ) {
      JDBCException e = session.getFactory().getSQLExceptionHelper().convert(
          sqle,
          "could not lock: " + MessageHelper.infoString( lockable, id, session.getFactory() ),
          sql
        );
      throw new PessimisticLockException("could not obtain pessimistic lock", e, object);
View Full Code Here

TOP

Related Classes of org.hibernate.JDBCException

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.