今天同事在写接口时,出现SQL错误
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 'key, linkman, linkphone, num, orderDetail, ordernum, orderstatus, ordertime, ord' at line 1
null id in com.ctcp.entity.LCD_Order entry (don't flush the Session after an exception occurs)
看了一眼,发现可能是SQL关键字的问题,因此修改了实体类的注入@Column(name = [key])等,在有关键字的地方都用[ ]括起来就OK了。假如是用hbm.xml文件来配置实体类与表的关系的话,如
<many-to-one name="infoUser" class="com.master.hibernate.model.InfoUser" fetch="select">
</many-to-one>
在column name="USER"里加上[] 方括号就好啦.
同时提供sql关键字网页,要找是否为关键字可ctrl+f查询
http://www.php100.com/manual/pgsql/sql-keywords-appendix.html