2020年12月21日星期一

Relation and differences between spring.jpa.generate-ddl and spring.jpa.hibernate.ddl-auto

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: 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

https://stackoverflow.com/questions/65401999/relation-and-differences-between-spring-jpa-generate-ddl-and-spring-jpa-hibernat December 22, 2020 at 09:05AM

没有评论:

发表评论