programming/ibatis mybatis

[ibatis] in 조건 생성하기

labj 2013. 10. 17. 13:29

[ibatis] in 조건 생성하기

 

* ctrl

  List<String> option_state_no = new ArrayList<String>();
  option_state_no.add("1");
  option_state_no.add("2");
  condition.put("option_state_no", option_state_no);
  
  List<Goods> goodsList = goodsService.getList(condition);

 

* svc
 public List<Goods> getList(Map<String, Object> condition) throws Exception {
  return goodsDao.getList(condition); 
 }

 

* dao
 @SuppressWarnings("unchecked")
 @Override
 public List<Goods> getList(Map<String, Object> condition) throws Exception {
  return (List<Goods>)sqlMap.queryForList("goods.list",condition);
 }

 

* sql
<isNotEmpty property="option_state_list" prepend="AND">
<![CDATA[
 b.STATE
]]>
<iterate prepend="IN" property="option_state_no" open="(" close=")" conjunction=",">
 #option_state_no[]#
</iterate>
</isNotEmpty>

 

[ibatis] in 조건 생성하기