Ensure ddl-auto=none for non-embedded database
A more thorough check is needed to avoid the false assumption that the DataSource is embedded just because an embedded database is on the classpath. You really have to try and look in the connection metadata, so that's what we now do. Fixes gh-621, fixes gh-373
This commit is contained in:
@@ -935,13 +935,22 @@ and {sc-spring-boot-autoconfigure}/orm/jpa/JpaBaseConfiguration.{sc-ext}[`JpaBas
|
||||
for more details.
|
||||
|
||||
|
||||
[[howto-use-custom-entity-manager]]
|
||||
=== Use a custom EntityManagerFactory
|
||||
To take full control of the configuration of the
|
||||
`EntityManagerFactory`, you need to add a `@Bean` named
|
||||
"entityManagerFactory". To avoid eager initialization of JPA
|
||||
infrastructure Spring Boot autoconfiguration does not switch on its
|
||||
entity manager based on the presence of a bean of that type. Instead
|
||||
it has to do it by name.
|
||||
|
||||
|
||||
[[howto-use-traditional-persistence-xml]]
|
||||
=== Use a traditional persistence.xml
|
||||
Spring doesn't require the use of XML to configure the JPA provider, and Spring Boot
|
||||
assumes you want to take advantage of that feature. If you prefer to use `persistence.xml`
|
||||
then you need to define your own `@Bean` of type `LocalEntityManagerFactoryBean`, and set
|
||||
the persistence unit name there.
|
||||
then you need to define your own `@Bean` of type `LocalEntityManagerFactoryBean` (with
|
||||
id "entityManagerFactory", and set the persistence unit name there.
|
||||
|
||||
See
|
||||
https://github.com/spring-projects/spring-boot/blob/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaBaseConfiguration.java[`JpaBaseConfiguration`]
|
||||
|
||||
@@ -1189,7 +1189,6 @@ See the '<<howto.adoc#howto-separate-entity-definitions-from-spring-configuratio
|
||||
how-to.
|
||||
|
||||
|
||||
|
||||
[[boot-features-spring-data-jpa-repositories]]
|
||||
==== Spring Data JPA Repositories
|
||||
Spring Data JPA repositories are interfaces that you can define to access data. JPA
|
||||
@@ -1238,9 +1237,15 @@ following to your `application.properties`.
|
||||
|
||||
[indent=0]
|
||||
----
|
||||
spring.jpa.hibernate.ddl-auto="create-drop"
|
||||
spring.jpa.hibernate.ddl-auto=create-drop
|
||||
----
|
||||
|
||||
Note that Hibernate's own internal property name for this (if you
|
||||
happen to remember it better) is `hibernate.hbm2ddl.auto`. You can set
|
||||
it, along with other Hibernate native properties, using
|
||||
`spring.jpa.properties.*` (the prefix is stripped before adding them
|
||||
to the entity manager). Also relevant:
|
||||
`spring.jpa.generate-ddl=false` switches off all DDL generation.
|
||||
|
||||
|
||||
[[boot-features-nosql]]
|
||||
|
||||
Reference in New Issue
Block a user