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

Viewed 945

Is there a way to quickly get initial SQL script for the database that is being generated by hibernating through ddl-auto property?

I would like to get an initial SQL script for the flyway as a quick start.

2 Answers
  1. use property spring.jpa.show-sql = true and it will print all script on console in format.

hibernate scripts on console

  1. use ddl-auto as you did and take backup of schema for your respective DB and use that as initial script

example - mysql , postgres

You can see the DDL script generated by Hibernate in a Spring boot application by setting the logging level of Hibernate to debug mode in the application.properties file of your project.

logging.level.org.hibernate.SQL=DEBUG
Related