HHH-8636 Wrapping all exceptions into PersistenceException in HibernatePersistenceProvider
This commit is contained in:
parent
e135566c0e
commit
485096a78b
|
@ -64,6 +64,7 @@ public class HibernatePersistenceProvider implements PersistenceProvider {
|
|||
public EntityManagerFactory createEntityManagerFactory(String persistenceUnitName, Map properties) {
|
||||
log.tracef( "Starting createEntityManagerFactory for persistenceUnitName %s", persistenceUnitName );
|
||||
|
||||
try {
|
||||
final EntityManagerFactoryBuilder builder = getEntityManagerFactoryBuilderOrNull( persistenceUnitName, properties );
|
||||
if ( builder == null ) {
|
||||
log.trace( "Could not obtain matching EntityManagerFactoryBuilder, returning null" );
|
||||
|
@ -73,6 +74,14 @@ public class HibernatePersistenceProvider implements PersistenceProvider {
|
|||
return builder.build();
|
||||
}
|
||||
}
|
||||
catch (PersistenceException pe) {
|
||||
throw pe;
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.debug( "Unable to build entity manager factory", e );
|
||||
throw new PersistenceException( "Unable to build entity manager factory", e );
|
||||
}
|
||||
}
|
||||
|
||||
protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String persistenceUnitName, Map properties) {
|
||||
return getEntityManagerFactoryBuilderOrNull( persistenceUnitName, properties, null );
|
||||
|
@ -86,10 +95,6 @@ public class HibernatePersistenceProvider implements PersistenceProvider {
|
|||
try {
|
||||
units = PersistenceXmlParser.locatePersistenceUnits( integration );
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
log.debug( "Unable to locate persistence units", e );
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.debug( "Unable to locate persistence units", e );
|
||||
throw new PersistenceException( "Unable to locate persistence units", e );
|
||||
|
|
Loading…
Reference in New Issue