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


在學習hibernate一對多映射關系時,根據視頻學習的時候,例子是顧客和訂單的問題,一個顧客有多個訂單。按照視頻中的敲代碼出現了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 hibernate-mapping PUBLIC "-//Hibernate Mapping DTD 3.0"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-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>
</hibernate-mapping>

后來將表名改為table1就運行成功了


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



猜您在找 解決:[Err] 1064 - 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 【異常】MySQL建表報錯: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"' at line 1 ERROR 1064 (42000): 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 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 '"id", SQL語句報錯:You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near php"> [Err] 1064 - 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 ''

php ERROR 1064 (42000): 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 '11. set password for 'root'@'localhost' 報錯--->java.sql.SQLSyntaxErrorException: 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 'delect from testd Mysql語法錯誤之> 1064 - 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' MySql 執行語句錯誤 Err] 1064 - 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

 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM