Skip to content

Commit

Permalink
Avoid custom properties processing
Browse files Browse the repository at this point in the history
EntityManagerFactoryBuilder does not currently use the JpaProperties to
initialize the `ddl-auto` and `naming-strategy` parameter automatically.

We can remove that customization. In that case, we have to specify the
`ddl-auto` flag explicitly as the code that auto-detects the value based
 on the database type is not executed anymore.
  • Loading branch information
snicoll committed Aug 7, 2015
1 parent c633389 commit 9e8ed95
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/main/java/demo/customer/CustomerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.autoconfigure.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -33,12 +32,11 @@ public DataSource customerDataSource() {

@Bean
public LocalContainerEntityManagerFactoryBean customerEntityManager(
EntityManagerFactoryBuilder builder, JpaProperties jpaProperties) {
EntityManagerFactoryBuilder builder) {
return builder
.dataSource(customerDataSource())
.packages(Customer.class)
.persistenceUnit("customers")
.properties(jpaProperties.getHibernateProperties(customerDataSource()))
.build();
}

Expand Down
4 changes: 1 addition & 3 deletions src/main/java/demo/order/OrderConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.autoconfigure.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -30,12 +29,11 @@ public DataSource orderDataSource() {

@Bean
public LocalContainerEntityManagerFactoryBean orderEntityManager(
EntityManagerFactoryBuilder builder, JpaProperties jpaProperties) {
EntityManagerFactoryBuilder builder) {
return builder
.dataSource(orderDataSource())
.packages(Order.class)
.persistenceUnit("orders")
.properties(jpaProperties.getHibernateProperties(orderDataSource()))
.build();
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
spring.jpa.properties.hibernate.hbm2ddl.auto=create

app.customer.datasource.url=jdbc:h2:mem:customers;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
app.customer.datasource.driver-class-name=org.h2.Driver

Expand Down

0 comments on commit 9e8ed95

Please sign in to comment.