在sql语法中使用Hibernate import.sql erorr

时间:2017-03-07 20:57:17

标签: sql hibernate jpa

在Spring启动应用程序中,我正在尝试使用我的sql架构加载启动import.sql文件以测试应用程序。奇怪的问题,因为当我手动将其添加到我的数据库时,相同的sql文件可以正常工作。

import.sql示例:

INSERT INTO car
(name, description, price) VALUES
('Audi Q7', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse libero ex.', 150),
('Audi A4', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse libero ex.', 79.99),
...

spring boot startup listing:

Listing on GitHubGist

错误样本:

HHH000388: Unsuccessful: INSERT INTO car
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
HHH000388: Unsuccessful: (name, description, price) VALUES
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'name, description, price) VALUES' at line 1
...

1 个答案:

答案 0 :(得分:2)

这是因为import.sql中的条目不应跨越多行。 Hibernate每行读取它并执行读取的每一行作为单个语句。