単純なモデル オブジェクトを保存するときに、休止状態から 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 を使用しているかどうかはわかりません。