Missing semicolons at line-end of JPA-generated sq

2020-07-17 14:18发布

问题:

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?

回答1:

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.



标签: java mysql sql jpa