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