Affects: all
Changing a catch block parameter is very discouraged.
The change will affect two methods into two different classes.
In buildNativeEntityManagerFactory()
in org.springframework.orm.jpa.AbstractEntityManagerFactoryBean
and in processLocalProperty(PropertyTokenHolder, PropertyValue)
in org.springframework.beans.AbstractNestablePropertyAccessor
.
For example the method buildNativeEntityManagerFactory() must be like this:
private EntityManagerFactory buildNativeEntityManagerFactory() {
EntityManagerFactory emf;
try {
emf = createNativeEntityManagerFactory();
}
catch (PersistenceException ex) {
PersistenceException persistenceException = ex;
if (persistenceException.getClass() == PersistenceException.class) {
// Plain PersistenceException wrapper for underlying exception?
// Make sure the nested exception message is properly exposed,
// along the lines of Spring's NestedRuntimeException.getMessage()
Throwable cause = persistenceException.getCause();
if (cause != null) {
String message = persistenceException.getMessage();
String causeString = cause.toString();
if (!message.endsWith(causeString)) {
persistenceException = new PersistenceException(message + "; nested exception is " + causeString, cause);
}
}
}
if (logger.isErrorEnabled()) {
logger.error("Failed to initialize JPA EntityManagerFactory: " + persistenceException.getMessage());
}
throw persistenceException;
}
JpaVendorAdapter jpaVendorAdapter = getJpaVendorAdapter();
if (jpaVendorAdapter != null) {
jpaVendorAdapter.postProcessEntityManagerFactory(emf);
}
if (logger.isInfoEnabled()) {
logger.info("Initialized JPA EntityManagerFactory for persistence unit '" + getPersistenceUnitName() + "'");
}
return emf;
}
Comment From: sbrannen
Superseded by #27877