For a Spring Boot
app (2.4.1) working with Spring Data JPA
, with @Entity
classes based with the javax.persistence
annotations. For a application.properties
exists these two properties:
spring.jpa.generate-ddl
spring.jpa.hibernate.ddl-auto
Thanks to STS, the following descriptions are available:
spring.jpa.generate-ddl
spring.jpa.generate-ddl
java.lang.Boolean
Default: false
Whether to initialize the schema on startup.
spring.jpa.hibernate.ddl-auto
spring.jpa.hibernate.ddl-auto
java.lang.String
DDL mode. This is actually a shortcut for the "hibernate.hbm2ddl.auto" property.
Defaults to "create-drop" when using an embedded database and no schema manager was detected.
Otherwise, defaults to "none"
- When is used the
spring.jpa.generate-ddl
? - When is mandatory use the
spring.jpa.generate-ddl
approach? What scenario?
I did realise that it is ignored and really is mandatory use spring.jpa.hibernate.ddl-auto
, it for the following scenario:
- For the
H2
in-memory database - the schema is created through theschema.sql
file and defining thespring.jpa.hibernate.ddl-auto
property as none, then in this casespring.jpa.generate-ddl
is totally ignored.
Question:
- What is the relation (if exists) and differences between
spring.jpa.generate-ddl
andspring.jpa.hibernate.ddl-auto
?
I found these posts, and in someway is not clear when is mandatory use spring.jpa.generate-ddl