当前位置: 首页 >数据库 > 解决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)

解决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)

在学习hibeate一对多映射关系时,根据视频学习的时候,例子是顾客和订单的问题,一个顾客有多个订单。按照视频中的敲代码出现了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)

 

原因是order是mysql关键字,不能做为表名

 

<?xml version="1.0"?><!DOCTYPE hibeate-mapping PUBLIC "-//Hibeate Mapping DTD 3.0""http://hibeate.sourceforge.net/hibeate-mapping-3.0.dtd"><hibeate-mapping package="com.cqupt.dayday"><class name="Order" table="order1"><id name="orderId" type="java.lang.Integer"><column name="order_id"/><!--指定主键的生成方式, native:使用数据库本地方式--><generator class="native"/></id><property name="orderName" type="java.lang.String"><column name="order_name"/></property><!--映射多对一的关联关系--><many-to-one name="customer" class="Customer" column="customer_id"></many-to-one></class></hibeate-mapping>

后来将表名改为table1就运行成功了

作者:何甜甜在吗
来源链接:https://www.cnblogs.com/Hdaydayup/p/6497268.html

版权声明:
1、JavaClub(https://www.javaclub.cn)以学习交流为目的,由作者投稿、网友推荐和小编整理收藏优秀的IT技术及相关内容,包括但不限于文字、图片、音频、视频、软件、程序等,其均来自互联网,本站不享有版权,版权归原作者所有。

2、本站提供的内容仅用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯相关权利人及本网站的合法权利。
3、本网站内容原作者如不愿意在本网站刊登内容,请及时通知本站(javaclubcn@163.com),我们将第一时间核实后及时予以删除。





本文链接:https://www.javaclub.cn/database/117893.html

标签:SQL_syntax
分享给朋友:

“解决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)” 的相关文章

JDBC工具类(DButil) 2022年05月13日 09:13:25
全面解析Redis 2022年05月13日 10:22:02
mysql递归查询 2022年06月06日 18:26:30
mysql查询各分区数据量大小 2022年06月10日 23:41:45
Mysql 查询区分大小写的两种方法 2022年06月11日 20:53:24
MySQL查询表中的数据是否存在 2022年06月13日 13:46:57