HHH-10664 - Prep 6.0 feature branch - merge hibernate-entitymanager into hibernate-core (have HibernateException extend JPA PersistenceException)
This commit is contained in:
parent
f4d8a9d850
commit
8ef423a1b3
|
@ -6,17 +6,17 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate;
|
package org.hibernate;
|
||||||
|
|
||||||
|
import javax.persistence.PersistenceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base exception type for Hibernate exceptions.
|
* The base exception type for Hibernate exceptions.
|
||||||
* <p/>
|
* <p/>
|
||||||
* Note that all {@link java.sql.SQLException SQLExceptions} will be wrapped in some form of
|
* Note that all {@link java.sql.SQLException SQLExceptions} will be wrapped in some form of
|
||||||
* {@link JDBCException}.
|
* {@link JDBCException}.
|
||||||
*
|
*
|
||||||
* @see JDBCException
|
|
||||||
*
|
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
*/
|
*/
|
||||||
public class HibernateException extends RuntimeException {
|
public class HibernateException extends PersistenceException {
|
||||||
/**
|
/**
|
||||||
* Constructs a HibernateException using the given exception message.
|
* Constructs a HibernateException using the given exception message.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1240,6 +1240,11 @@ public final class SessionImpl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (RuntimeException e) {
|
catch (RuntimeException e) {
|
||||||
|
if ( !getSessionFactory().getSessionFactoryOptions().isJpaBootstrap() ) {
|
||||||
|
if ( e instanceof HibernateException ) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
//including HibernateException
|
//including HibernateException
|
||||||
throw convert( e );
|
throw convert( e );
|
||||||
}
|
}
|
||||||
|
@ -1258,6 +1263,12 @@ public final class SessionImpl
|
||||||
delayedAfterCompletion();
|
delayedAfterCompletion();
|
||||||
}
|
}
|
||||||
catch (RuntimeException e) {
|
catch (RuntimeException e) {
|
||||||
|
if ( !getSessionFactory().getSessionFactoryOptions().isJpaBootstrap() ) {
|
||||||
|
if ( e instanceof HibernateException ) {
|
||||||
|
handlePersistenceException( (HibernateException) e );
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
//including HibernateException
|
//including HibernateException
|
||||||
throw convert( e );
|
throw convert( e );
|
||||||
}
|
}
|
||||||
|
|
|
@ -325,6 +325,14 @@ public class CriteriaHQLAlignmentTest extends QueryTranslatorTestCase {
|
||||||
}
|
}
|
||||||
assertEquals( 1, count.longValue() );
|
assertEquals( 1, count.longValue() );
|
||||||
}
|
}
|
||||||
|
catch ( SQLGrammarException ex ) {
|
||||||
|
if ( ! getDialect().supportsTupleCounts() ) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
catch (PersistenceException e) {
|
catch (PersistenceException e) {
|
||||||
SQLGrammarException cause = assertTyping( SQLGrammarException.class, e.getCause() );
|
SQLGrammarException cause = assertTyping( SQLGrammarException.class, e.getCause() );
|
||||||
if ( ! getDialect().supportsTupleCounts() ) {
|
if ( ! getDialect().supportsTupleCounts() ) {
|
||||||
|
@ -334,14 +342,6 @@ public class CriteriaHQLAlignmentTest extends QueryTranslatorTestCase {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( SQLGrammarException ex ) {
|
|
||||||
if ( ! getDialect().supportsTupleCounts() ) {
|
|
||||||
// expected
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally {
|
finally {
|
||||||
t.rollback();
|
t.rollback();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
|
@ -70,12 +70,12 @@ public class TransactionTimeoutTest extends BaseCoreFunctionalTestCase {
|
||||||
session.persist( new Person( "Lukasz", "Antoniak" ) );
|
session.persist( new Person( "Lukasz", "Antoniak" ) );
|
||||||
transaction.commit();
|
transaction.commit();
|
||||||
}
|
}
|
||||||
catch (PersistenceException e) {
|
|
||||||
assertTyping( TransactionException.class, e.getCause() );
|
|
||||||
}
|
|
||||||
catch (TransactionException e) {
|
catch (TransactionException e) {
|
||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
|
catch (PersistenceException e) {
|
||||||
|
assertTyping( TransactionException.class, e.getCause() );
|
||||||
|
}
|
||||||
finally {
|
finally {
|
||||||
session.close();
|
session.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,15 +60,12 @@ public class OrmVersionTest {
|
||||||
hp.createContainerEntityManagerFactory( pui, Collections.EMPTY_MAP );
|
hp.createContainerEntityManagerFactory( pui, Collections.EMPTY_MAP );
|
||||||
Assert.fail( "expecting 'invalid content' error" );
|
Assert.fail( "expecting 'invalid content' error" );
|
||||||
}
|
}
|
||||||
catch ( InvalidMappingException expected ) {
|
catch ( InvalidMappingException | AnnotationException expected ) {
|
||||||
// expected condition
|
// expected condition
|
||||||
}
|
}
|
||||||
catch ( PersistenceException expected ) {
|
catch ( PersistenceException expected ) {
|
||||||
// expected condition
|
// expected condition
|
||||||
}
|
}
|
||||||
catch (AnnotationException expected) {
|
|
||||||
// expected condition
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PersistenceUnitInfoImpl implements PersistenceUnitInfo {
|
public static class PersistenceUnitInfoImpl implements PersistenceUnitInfo {
|
||||||
|
|
Loading…
Reference in New Issue