使用save()播放框架JPA问题

3 java sql persistence jpa playframework

我正在尝试在数据库中保存一个简单的对象,但它给了我一些问题.

这是我的对象类:

@Entity
@Table(name="lines")
public class Line extends GenericModel{

    @Id
    @Column(name="line_id")
    private int id;

    @Column(name="line_text")
    private String text;

    @Column(name="line_postid")
    private int postid;

    @Column(name="line_position")
    private int position;
}
Run Code Online (Sandbox Code Playgroud)

这就是我在控制器中的含义:

Line l = new Line();
l.setPosition(0);
l.setPostid(4);
l.setText("geen");
l.save();
Run Code Online (Sandbox Code Playgroud)

我正在为其他模特做同样的事情,我没有任何问题,只有这一个给我带来了问题.当我刷新浏览器时,我得到: PersistenceException occured : org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update

我还添加jpa.debugSQL=true了我的配置,在我的控制台中我得到了:

Caused by: java.sql.BatchUpdateException: 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 (line_position, line_postid, line_text, line_id) values (0, 4, 'geen', 0)' at line 1

浏览器也显示了这一点:This exception has been logged with id 66k3glbb6但我不知道在哪里可以查看我的日志,所以如果有人可以告诉我那个呢?

axt*_*avt 7

lines 在MySQL中是一个保留字,你需要按如下方式转义它:

@Table(name="`lines`") // Hibernate way
Run Code Online (Sandbox Code Playgroud)

要么

@Table(name="\"lines\"") // JPA standard way
Run Code Online (Sandbox Code Playgroud)