Instructing JPA creating schema
spring.jpa.hibernate.ddl-auto
instructs how JPA creating a database schema.spring.jpa.hibernate.ddl-auto
explicitly; these values are none
, validate
, update
, create-drop
. Database categories
Databases are categorized into embedded or real databases.
An embedded database is detected by looking at the Connection
type: hsqldb
, h2
and derby
are embedded, the rest are considered as real databases.
Ddl-auto default value
Spring Boot chooses a default ddl-auto value according to databae catogories.
for an embedded database:
spring.jpa.hibernate.ddl-auto = create-drop
for an real database:
spring.jpa.hibernate.ddl-auto = none
Be careful when switching from in-memory to a “real” database that you don’t make assumptions about the existence of the tables and data in the new platform. You either have to set ddl-auto
explicitly or use one of the other mechanisms to initialize the database.
No comments:
Post a Comment