Hibernate记录 之Hibernate写sql语句中in的写法

普通占位符  :shopId   

In的占位符::(hids)   之后需要   qry.setParameterList(“hids”, hids)  

具体代码 :

public List<String> getHouseLists(String shopId, List<String> hids) {
	String sql = " SELECT id FROM JC_House WHERE shopId = :shopId AND h.id IN (:hids) ";
	Query qry = super.getSession().createSQLQuery(sql).setString("shopId", shopId);
	if (hids != null && hids.size() > 0) {
		qry.setParameterList("hids", hids);
	}
	List<String> houseList = qry.list();
	return houseList;
}

 

    原文作者:w348399060
    原文地址: https://blog.csdn.net/w348399060/article/details/100932746
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞