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

Suneel

How can I see the DDL SQL generated by Hibernate for building the schema from the JPA mappings? I am using the embedded HSQL db.

I tried the following and none of them worked in Spring-Boot 1.3.5.RELEASE.

Those only show me the sql issued by Hibernate for queries. I am looking for the DDL schema sql issued by Hibernate due the following property:

spring.jpa.hibernate.ddl-auto=create-drop
Riggs

Try with this property and value:

javax.persistence.schema-generation.scripts.action=create

Do not forget to also set this property:

javax.persistence.schema-generation.scripts.create-target=my-schema.sql

From the JPA 2.1 Specifiation, page 370:

javax.persistence.schema-generation.scripts.action

The javax.persistence.schema-generation.scripts.action property specifies which scripts are to be generated by the persistence provider. The values for this property are none, create, drop-and-create, drop. A script will only be generated if the script target is specified. If this property is not specified, it is assumed that script generation is not needed or will

In Spring Boot you can define those two properties in your application.properties file:

spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=build/my-schema.sql
spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create

Here is a blog post about JPA schema generation with further information about these and other properties: http://www.thoughts-on-java.org/standardized-schema-generation-data-loading-jpa-2-1/

Collected from the Internet

Please contact javaer1[email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

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

How to get ddl auto generated script in Spring boot JPA/Hibernate?

Spring Boot - How to set the default schema for PostgreSQL?

Spring boot ddl auto generator

importing procedures through schema.sql spring boot

mule4/java convert Sql ddl schema to json schema

spring boot sql database DML and DDL scripts

Spring Boot schema.sql - drop db schema on restart

How to run a custom ddl script on startup of Spring Boot 2

Spring Boot "schema.sql" When Using JPA

Generate DDL with spring boot using a custom delimiter

Using Spring Boot, how do I see debug info for Zuul?

How to configure spring-boot with security for custom SQL schema user-role?

How to dynamically change schema in spring boot Entities?

How to only generate envers schema in a spring boot application?

SQL DDL to parse JSON schema file

How to export BigQuery table schema as DDL

How to set schema in datasource for DB2 connection in Spring boot

How to see the classes generated by lombok in maven spring boot application

How to export DDL for non-default schema in Oracle SQL Developer

Initializing an Empty Table using schema.sql in Spring Boot

Spring export schema DDL to the database in runtime

Spring boot schema.sql not working with mysqldump file

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

how to resolve error executing ddl commands in spring boot

How to see specify class list in spring-boot?

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

Spring Boot and H2 Table Population Error: org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL

Spring boot exception error executing ddl