Log JPA schema creation with Hibernatewednesday, april 15, 2015
The JPA provider can create the database schema from the Entity beans.
This behaviour is configured in the
You can display the SQL scripts which were used to generate the database schema with Hibernate.
Therefore you configure the
hibernate.show_sql property to
true and the
hibernate.hbm2ddl.auto property to
create in your
<properties> ... <property name="hibernate.show_sql" value="true" /> <property name="hibernate.hbm2ddl.auto" value="create" /> </properties>
Also set the log level for the
org.hibernate.tool.hbm2ddl logger to
The create SQL statements will appear in the log:
org.hibernate.tool.hbm2ddl.SchemaExport execute Hibernate: create table customers (id bigint not null, ... ... org.hibernate.tool.hbm2ddl.SchemaExport execute
Found the post useful? Subscribe to my newsletter for more free content, tips and tricks on IT & Java:
All opinions are my own and do not reflect those of my employer or colleagues.