【正文】
fw from TblFwxx fw hql += where 1=1 。 if (()!=null){ hql += and like 39。% + () + %39。 。 } ... } 代碼啰嗦,不易維護(hù) 不方便使用參數(shù)查詢,安全性和執(zhí)行效率不好 使用 Criteria查詢代碼更簡潔 使用 Criteria查詢 以對象的方式構(gòu)建查詢 創(chuàng)建 Criteria對象 模糊查詢 大于等于 和 小于等于 支持 in和between 數(shù)組類型 支持類似EL表達(dá)式的屬性瀏覽語法 可以增加多個(gè)排序規(guī)則 使用 Criteria查詢 測試程序和運(yùn)行效果 生成的 SQL語句: Hibernate: select as fwid1_0_, as uid1_0_, as jdid1_0_, as lxid1_0_, as shi1_0_, as ting1_0_, as fwxx1_0_, as zj1_0_, as title1_0_, as date1_0_, as telephone1_0_, as lxr1_0_ from TBL_FWXX this_ where like ? and =? and =? and in (?, ?) order by asc 總結(jié) HQL的全稱是? 和 SQL相比, HQL有哪些特點(diǎn)? HQL語句為: select , from TblJd jd。怎樣獲得并顯示查詢結(jié)果? 使用 39。?39。做占位符的參數(shù)查詢,怎樣設(shè)置參數(shù)的值? 命名參數(shù)查詢的語法是? 怎樣創(chuàng)建 Criteria查詢對象?