简体   繁体   English

sql语法中的Hibernate import.sql错误:不成功:INSERT INTO

[英]Hibernate import.sql error in sql syntax: Unsuccessful: INSERT INTO

In Spring boot app I'm trying to load on startup import.sql file with my sql schema for testing app. 在春季启动应用程序中,我试图使用我的sql模式加载启动import.sql文件以测试应用程序。 Weird problem because the same sql file works when I'm adding its by hand to my DB. 奇怪的问题,因为当我手动将其添加到数据库时,同一个sql文件可以工作。

sample of import.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: spring boot启动清单:

Listing on GitHubGist 在GitHubGist上列出

sample of error: 错误样本:

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
...

That is because the entries in import.sql shouldn't span multiple lines. 这是因为import.sql的条目不应跨越多行。 Hibernate reads it per line and executes each line read as a single statement. Hibernate每行读取一次,并将每行读取为一条语句执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM