天天看點

CHECK the manual that corresponds TO your MySQL SERVER VERSION FOR the RIGHT syntax TO USE near.....

使用spingdata+jpa+hibernate來對資料庫進行插入操作的時候,出現了一個報錯資訊,說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......
           

這就很奇怪了,通過orm架構向資料庫中存儲資料,sql是架構自動生成的,不應該有錯啊。後來經過仔細檢視,才發現是因為我的實體名字是order,并且沒有指定存入資料庫時資料庫的名字。那麼資料庫對應的表明預設就是order。但是又有mysql裡面有order關鍵字,是以就産生了上面的沖突。在@Entity裡面另外指定一個資料庫的表名就好了。比如@Entity(name=”t_order”)。花了一個小時的時間才找到問題的原因,記錄一下。