標籤:
ELECT t0.accusation_des, t0.submit_time, t0.result, t0.handle_time, t1.content, t4.nick_name,t5.content,t6.ask_title ,t7.state_name,t8.item_name,t9.school_name,t10.school_name,t12.school_name,t14.school_name FROM wxcommunity.t_accusation t0 left join wxcommunity.t_comment t1 on t1.commentId = t0.commentId LEFT JOIN wxcommunity.t_ask t2 ON t2.askId = t1.askId LEFT JOIN wxcommunity.t_school t9 ON t9.schoolId = t2.schoolId LEFT JOIN wxcommunity.t_answer t3 ON t1.answer_id = t3.answer_id LEFT JOIN wxcommunity.t_ask t11 on t11.askId = t3.askId LEFT JOIN wxcommunity.t_school t12 ON t12.schoolId = t11.schoolId LEFT JOIN wxcommunity.t_member t4 ON t4.userid = t0.userid left join wxcommunity.t_answer t5 on t5.answer_id = t0.answer_id LEFT JOIN wxcommunity.t_ask t13 on t13.askId = t5.askId LEFT JOIN wxcommunity.t_school t14 ON t14.schoolId = t13.schoolId LEFT JOIN wxcommunity.t_ask t6 on t6.askId = t0.askId LEFT JOIN wxcommunity.t_school t10 ON t10.schoolId = t6.schoolId LEFT JOIN wxcommunity.t_handle_state t7 on t7.stateId = t0.stateId LEFT JOIN wxcommunity.t_accusation_item t8 on t8.accusation_item_id = t0.accusation_item_id WHERE (t0.askId > 0 OR t0.answer_id > 0 OR t1.askId > 0 OR t1.answer_id > 0)
總結:1,帶有or邏輯關係的sql語句jpa查詢出錯,初步判斷jpa本身bug。
2,上述語句在資料庫中直接查詢(navicat執行sql語句)沒問題,但是用在java代碼中執行 executeNativeSql()出錯,開始時因mysql-connector-java查詢出錯查不出資料,換了一個mysql-connector-java5.1.30的能查出資料但是還是有錯(查詢記錄老是少了一條)。初步判斷java代碼中mysql-connector-java驅動本身缺陷。
mysql存入資料出錯總結