Reputation: 3255
I've setup a new Spring Boot application using Spring Data. I'm trying to perform a really simple query on the database, but the error logs are reporting that there's something wrong with the query, and I can't figure out why.
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 'lines line0_' at line 1
The Database Table is setup as follows;
BIGINT | id VARCHAR | name TEXT | storage_path TINYINT(1) | active
The Line entity looks like this;
@Entity
@Table(name="lines")
public class Line {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name="name")
private String name;
@Column(name="storage_path")
private String storagePath;
@Column(name="active", columnDefinition = "TINYINT(1)")
private Boolean active;
}
As I'm using Spring Data, my repository looks like this;
@Repository
public interface LineRepository extends CrudRepository<Line, Long> {
/**
* Return a list of lines by their active value
* @param active the active value
* @return List of lines
*/
public List<Line> getByActive(Boolean active);
}
All I'm trying to do it call the findAll() method on the LineRepository, but it's raising the error above.
EDIT: Below is the query being executed, I can't see anything wrong with it;
SELECT
l
FROM
Line l */ select
line0_.id as id1_0_,
line0_.active as active2_0_,
line0_.name as name3_0_,
line0_.storage_path as storage_4_0_
from
lines line0_
Upvotes: 0
Views: 3658
Reputation: 3255
It turns out that 'lines' is a reserved word in MySQL, hence why the queries where invalid.
I've changed the name of my table and it has resolved the issue.
Upvotes: 1