简体   繁体   中英

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. Weird problem because the same sql file works when I'm adding its by hand to my DB.

sample of 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

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. Hibernate reads it per line and executes each line read as a single statement.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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