Browse Source

Defensive null check in case Hibernate autoconfig is off

If the Hibernate autoconfig is not used to create an EntityManager
then I suppose it's possible that the JpaProperties might be null
when everything else is ready for the event to be published.

There's no test case because I think it's a corner case.

Fxies gh-1075
pull/1082/head
Dave Syer 12 years ago
parent
commit
8d6f003e9a
  1. 3
      spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/DataSourceInitializedPublisher.java

3
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/DataSourceInitializedPublisher.java

@ -73,6 +73,9 @@ class DataSourceInitializedPublisher implements BeanPostProcessor { @@ -73,6 +73,9 @@ class DataSourceInitializedPublisher implements BeanPostProcessor {
}
private boolean isInitializingDatabase() {
if (this.properties == null) {
return true; // better safe than sorry
}
Map<String, String> hibernate = this.properties
.getHibernateProperties(this.dataSource);
if (hibernate.containsKey("hibernate.hbm2ddl.auto")) {

Loading…
Cancel
Save