JPA生成的SQL脚本的行尾缺少分号 [英] Missing semicolons at line-end of JPA-generated sql script

查看:258
本文介绍了JPA生成的SQL脚本的行尾缺少分号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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 )

我认为这在标准SQL中有效吗?但是,它在MySQL中无效.有没有办法告诉JPA将分号添加到行尾?还是缺少它的原因是什么?

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?

推荐答案

从Hibernate 5.1.0开始,可以通过设置hibernate.hbm2ddl.delimiter属性来定义所生成SQL的行定界符,例如

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=";"

默认为无分隔符.

另请参阅对此票证的评论.

这篇关于JPA生成的SQL脚本的行尾缺少分号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆