Hibernate利用save()方法时报mysql语法错误

来源:互联网 发布:php简单论坛源码 编辑:程序博客网 时间:2024/06/05 18:51

在利用hibernate的session.save()方法生成table,并插入数据时,报了如下错误


ERROR: 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'ORDER (ORDER_NAME, CUSTOMER_ID) values ('aaa', 2)' at line 1

八月 07, 2017 12:05:23 下午 org.hibernate.AssertionFailure <init>

ERROR: HHH000099: an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session): org.hibernate.AssertionFailure: null id in n21.Order entry (don't flush the Session after an exception occurs)


检查后发现问题在标红字体那一段,然后把Order.hbm.xml中的 <class name="n21.Order" table="ORDER"> table="ORDER"改成ORDERS,看来,order是mysql的关键字啊

原创粉丝点击