mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-16 16:15:06 +00:00
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;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
/**
|
||||
* The base exception type for Hibernate exceptions.
|
||||
* <p/>
|
||||
* Note that all {@link java.sql.SQLException SQLExceptions} will be wrapped in some form of
|
||||
* {@link JDBCException}.
|
||||
*
|
||||
* @see JDBCException
|
||||
*
|
||||
* @author Gavin King
|
||||
*/
|
||||
public class HibernateException extends RuntimeException {
|
||||
public class HibernateException extends PersistenceException {
|
||||
/**
|
||||
* Constructs a HibernateException using the given exception message.
|
||||
*
|
||||
|
@ -1240,6 +1240,11 @@ private void fireRefresh(RefreshEvent event) {
|
||||
}
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
if ( !getSessionFactory().getSessionFactoryOptions().isJpaBootstrap() ) {
|
||||
if ( e instanceof HibernateException ) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
//including HibernateException
|
||||
throw convert( e );
|
||||
}
|
||||
@ -1258,6 +1263,12 @@ private void fireRefresh(Map refreshedAlready, RefreshEvent event) {
|
||||
delayedAfterCompletion();
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
if ( !getSessionFactory().getSessionFactoryOptions().isJpaBootstrap() ) {
|
||||
if ( e instanceof HibernateException ) {
|
||||
handlePersistenceException( (HibernateException) e );
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
//including HibernateException
|
||||
throw convert( e );
|
||||
}
|
||||
|
@ -325,6 +325,14 @@ public void testCountReturnValues() {
|
||||
}
|
||||
assertEquals( 1, count.longValue() );
|
||||
}
|
||||
catch ( SQLGrammarException ex ) {
|
||||
if ( ! getDialect().supportsTupleCounts() ) {
|
||||
// expected
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
catch (PersistenceException e) {
|
||||
SQLGrammarException cause = assertTyping( SQLGrammarException.class, e.getCause() );
|
||||
if ( ! getDialect().supportsTupleCounts() ) {
|
||||
@ -334,14 +342,6 @@ public void testCountReturnValues() {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
catch ( SQLGrammarException ex ) {
|
||||
if ( ! getDialect().supportsTupleCounts() ) {
|
||||
// expected
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
finally {
|
||||
t.rollback();
|
||||
s.close();
|
||||
|
@ -70,12 +70,12 @@ public void testTransactionTimeoutFailure() throws InterruptedException {
|
||||
session.persist( new Person( "Lukasz", "Antoniak" ) );
|
||||
transaction.commit();
|
||||
}
|
||||
catch (PersistenceException e) {
|
||||
assertTyping( TransactionException.class, e.getCause() );
|
||||
}
|
||||
catch (TransactionException e) {
|
||||
// expected
|
||||
}
|
||||
catch (PersistenceException e) {
|
||||
assertTyping( TransactionException.class, e.getCause() );
|
||||
}
|
||||
finally {
|
||||
session.close();
|
||||
}
|
||||
|
@ -60,15 +60,12 @@ public void testInvalidOrm1() {
|
||||
hp.createContainerEntityManagerFactory( pui, Collections.EMPTY_MAP );
|
||||
Assert.fail( "expecting 'invalid content' error" );
|
||||
}
|
||||
catch ( InvalidMappingException expected ) {
|
||||
catch ( InvalidMappingException | AnnotationException expected ) {
|
||||
// expected condition
|
||||
}
|
||||
catch ( PersistenceException expected ) {
|
||||
// expected condition
|
||||
}
|
||||
catch (AnnotationException expected) {
|
||||
// expected condition
|
||||
}
|
||||
}
|
||||
|
||||
public static class PersistenceUnitInfoImpl implements PersistenceUnitInfo {
|
||||
|
Loading…
x
Reference in New Issue
Block a user