0
保存簡單模型對象時,我從休眠狀態獲取mysql錯誤,但似乎無法找到問題所在。我的模型類:保存對象時Hibernate生成mysql錯誤
@Entity (name = "match")
public class Match {
@Id @GeneratedValue (strategy = GenerationType.AUTO)
private int matchId;
private int size;
private int maxSize;
@Temporal (TemporalType.DATE)
private Date createDate;
//setter & getters
}
,節約的方法,例如:
@Test
public void save()
{
Match match = new Match();
match.setMaxSize(10);
match.setSize(8);
match.setCreateDate(new Date());
Session session = Hibernate.getSessionFactory().openSession();
try
{
session.beginTransaction();
session.save(match);
session.getTransaction().commit();
} catch (HibernateException e)
{
session.getTransaction().rollback();
e.printStackTrace();
}
}
這是我從休眠發現了錯誤:
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 'match (createDate, maxSize, size) values ('2013-06-28', 10, 8)' at line 1
我認爲這可能是一種方言問題,但我不確定我在爲我的方言課使用org.hibernate.dialect.MySQLDialect。