Search in sources :

Example 1 with SQLExceptionConversionDelegate

use of org.hibernate.exception.spi.SQLExceptionConversionDelegate in project hibernate-orm by hibernate.

the class PostgreSQL81DialectTestCase method testTimeoutException.

@Test
public void testTimeoutException() {
    PostgreSQL81Dialect dialect = new PostgreSQL81Dialect();
    SQLExceptionConversionDelegate delegate = dialect.buildSQLExceptionConversionDelegate();
    assertNotNull(delegate);
    JDBCException exception = delegate.convert(new SQLException("Lock Not Available", "55P03"), "", "");
    assertTrue(exception instanceof PessimisticLockException);
}
Also used : SQLExceptionConversionDelegate(org.hibernate.exception.spi.SQLExceptionConversionDelegate) JDBCException(org.hibernate.JDBCException) SQLException(java.sql.SQLException) PessimisticLockException(org.hibernate.PessimisticLockException) Test(org.junit.Test)

Example 2 with SQLExceptionConversionDelegate

use of org.hibernate.exception.spi.SQLExceptionConversionDelegate in project hibernate-orm by hibernate.

the class PostgreSQL81DialectTestCase method testDeadlockException.

@Test
public void testDeadlockException() {
    PostgreSQL81Dialect dialect = new PostgreSQL81Dialect();
    SQLExceptionConversionDelegate delegate = dialect.buildSQLExceptionConversionDelegate();
    assertNotNull(delegate);
    JDBCException exception = delegate.convert(new SQLException("Deadlock Detected", "40P01"), "", "");
    assertTrue(exception instanceof LockAcquisitionException);
}
Also used : SQLExceptionConversionDelegate(org.hibernate.exception.spi.SQLExceptionConversionDelegate) JDBCException(org.hibernate.JDBCException) SQLException(java.sql.SQLException) LockAcquisitionException(org.hibernate.exception.LockAcquisitionException) Test(org.junit.Test)

Aggregations

SQLException (java.sql.SQLException)2 JDBCException (org.hibernate.JDBCException)2 SQLExceptionConversionDelegate (org.hibernate.exception.spi.SQLExceptionConversionDelegate)2 Test (org.junit.Test)2 PessimisticLockException (org.hibernate.PessimisticLockException)1 LockAcquisitionException (org.hibernate.exception.LockAcquisitionException)1