Spring Boot "schema.sql" When Using JPA

CBA110 :

When utilizing 'Spring Data JPA' the schema is created automatically if you have '@Repository' and '@Entity' annotated classes. Is there any reason why I may want to have the addition of a 'schema.sql' file in the resources folder? There does not seem to have any conflict if you happen to have it present. If so, which takes precedence in creating the structure of the database (tables, columns, etc)? JPA or the 'schema.sql' file when present?

CBA110 :

I found an answer according to the link below:

Database Initialization on Spring Boot

" In a JPA-based app, you can choose to let Hibernate create the schema or use schema.sql, but you cannot do both. Make sure to disable spring.jpa.hibernate.ddl-auto if you use schema.sql."

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Initializing an Empty Table using schema.sql in Spring Boot

How to persist when using Spring Boot with JPA

How to see the schema sql (DDL) in spring boot?

NullPointerException using Spring Boot JPA when trying to save to database

Why do my database customizations not get applied when using Spring Data JPA with Spring Boot?

When using Spring boot and Spring JPA - why can't I get schema generation for entities in dependency?

Spring boot schema.sql not working with mysqldump file

Why Spring Boot 2.0 application does not run schema.sql?

Spring Boot initialization with schema.sql and DDL auto generation?

importing procedures through schema.sql spring boot

Spring Boot schema.sql - drop db schema on restart

spring boot is executing data.sql and schema.sql twice?

Spring boot not executing schema.sql in integration tests

How to configure JPA + HIBERNATE using Spring Boot

Update Password Using Spring Boot and JPA Is Not Working

relate entities by reference using spring boot, JPA

Using a Hibernate filter with Spring Boot JPA

Spring Boot Service using Jpa repository Testing

Which return value should I use for the one-to-one table when using spring boot jpa?

MySQL java.sql.SQLSyntaxErrorException when editing object values and using save() in Spring Boot JPA

Spring Data JPA not using AttributeConverter in Spring Boot Application

spring data jpa repository inject fails using @Autowired in spring boot

Null pointer exception in CriteriaQuery using spring boot and spring data JPA

NonUniqueResultException thrown when using spring jpa "findtop"

Spring Boot fails to run schema.sql with dependency on spring-cloud-starter-config

Azure spring boot JPA

Spring Boot JPA - SQLIntegrityConstraintViolationException

Spring boot JPA DataIntegrityViolationException

Spring Boot jpa NoClassDefFoundError