我有hibernate实体,当我尝试将其插入MySQL数据库时,我得到异常:
@Entity
public class Pick {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int pid;
@OneToOne
private Match_soccer match;
@OneToOne
private Algo1 algo;
@Column(length = 100)
private String pick;
@Column(length = 5)
private double limit;
...
当我尝试使用hibernate插入MySQL数据库时:
Pick pick = new Pick();
pick.setMatch(match);
pick.setAlgo(a);
pick.setLimit(2.5);
pick.setPick("under");
PickDAO pd = new PickDAO();
pd.insertMatch(pick);
我得到MySQL exception:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'limit, match_mid, pick) values (1, 2.5, 9358, 'under')' at line 1
Limit
为MySQL保留字。将实体属性重命名为其他内容