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-ddlapproach? What scenario?
I did realise that it is ignored and really is mandatory use spring.jpa.hibernate.ddl-auto, it for the following scenario: The schema is created through the schema.sql file for H2 and spring.jpa.hibernate.ddl-auto is none, in this case spring.jpa.generate-ddl is totally ignored
Therefore:
What is the relation (if exists) and differences between spring.jpa.generate-ddl and spring.jpa.hibernate.ddl-auto?
I found these posts, and in someway is not clear when is mandatory use spring.jpa.generate-ddl
- H2 schema still generated when spring.jpa.generate-ddl=false
- Hibernate Annotation relations does not work with spring.jpa.generate-ddl=true
- tables not creating in spring boot v2.2.6.RELEASE postgres
没有评论:
发表评论