我使用以下代码向 JPA 插入数据,当我尝试提交时出现错误,该对象包含完整数据,所以我不明白我在这里遗漏了什么,知道吗?
entityManager.getTransaction().begin();
entityManager.persist(object);
entityManager.getTransaction().commit();
带有所有 getter 和 setter 的实体看起来像这样
@Entity
public class LeaveRequest {
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private int id;
private String type;
private String from;
private String to;
private String length;
private String state;
public int getId() {
return id;
}
错误是:
Internal Exception: java.sql.SQLSyntaxErrorException: Syntax error: Encountered "FROM" at line 1, column 31.
Error Code: 20000
Call: INSERT INTO LEAVEREQUEST (ID, FROM, LENGTH, STATE, TO, TYPE) VALUES (?, ?, ?, ?, ?, ?)
bind => [6 parameters bound]
Query: InsertObjectQuery(LeaveRequest [id=1, type=VACATION, from=2012-12-27, to=2012-12-27, length=1 day, state=Rejected])