其實造成這個問題的根本原因還是對hibernate的使用不太了解改成這樣就沒錯了from Project o where = and oisDeleted=? and oprjName like ? querysetString(i %+實際查詢條件+%) 注意參數中第一個百分號的左邊與第二個百分號的右邊都沒有單引號這和平時寫SQL語句是不同的要特別關注一下另外還應該了解一下倆點的區別
HQLfrom Project o where = and PRJ_NAME like %strCond%//這裡PRJ_NAME 應該是數據庫表中的實際字段名HQLfrom Project o where = and oPRJ_NAME like %strCond%//這裡PRJ_NAME 應該是實體類的屬性名
HQLfrom Project o where = and PRJ_NAME like ?//這裡的?不視為占位參數HQLfrom Project o where = and PRJ_NAME like ?//設置參數值時會自動在參數值兩邊加上單引號
From:http://tw.wingwit.com/Article/program/Java/ky/201311/28423.html