Hibernate 错误处理

1. 在处理映射 1 对 n 时,Customer类为 1, Order类为 n,对象关系映射文件中没有错误,<many to one> 也正确,表名通类名。

 但是,在执行插入时,发生两个错误:

 org.hibernate.exception.SQLGrammarException: could not execute statement
 Caused by: 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 'ORDER (ORDER_NAME, CUSTOMER_ID) values ('order1', 6)' at line 1

插入不了,数据库中生成了一个Customer表,但没有数据,Order表则是根本没有生成。找错误,差不多一小时没有找到,,最后改了一下表名 Customers, 程序就执行成功了,不知为何?

 

posted @ 2016-08-26 22:45  岳灵珊  阅读(106)  评论(0编辑  收藏  举报