twistezo
twistezo

Reputation: 576

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

Upvotes: 1

Views: 826

Answers (1)

Naros
Naros

Reputation: 21103

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.

Upvotes: 4

Related Questions