Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing semicolons at line-end of JPA-generated sql script

Tags:

java

sql

mysql

jpa

I am using JPA to generate a script for creating database tables based on my entities:

javax.persistence.schema-generation.scripts.action=create
javax.persistence.schema-generation.scripts.create-target=db_setup.sql

The file is generated with the correct tables, however the statements do not end with a semicolon, for example:

create table hibernate_sequence (next_val bigint)
insert into hibernate_sequence values ( 1 )
insert into hibernate_sequence values ( 1 )

I assume this is valid in standard SQL? However, it is not valid in MySQL. Is there a way to tell JPA to add the semicolons to the end of the line? Or what else could be the reason that it is missing?

like image 852
Dominic Avatar asked Jan 24 '18 13:01

Dominic


1 Answers

Since Hibernate 5.1.0, the line delimiter for the generated SQL can be defined by setting the hibernate.hbm2ddl.delimiter property, e.g.

hibernate.hbm2ddl.delimiter=";"

The default is no delimiter.

See also comments on this ticket.

like image 75
Dominic Avatar answered Sep 29 '22 12:09

Dominic