有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Hibernate在保存对象时生成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();
    }
}

这是我从hibernate得到的错误:

 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。冬眠地方话我在方言课上讲了我的方言


共 (1) 个答案