在利用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的关键字啊
本文介绍了一种常见的Hibernate操作数据库时出现的问题:使用MySQL关键字作为表名导致的语法错误。通过修改表名避免了这一问题。
876

被折叠的 条评论
为什么被折叠?



