Tuesday, August 19, 2008

Ibatis - Select

Dao function to call ibatis xml
public List getActionListString type)
{ Map m = new HashMap();
m.put("type",datatype);
return getSqlMapClientTemplate().queryForList("xmlSQL.getActionList", m);
}

xmlSQL file sql statement
<select id="getActionList" parameterClass="java.util.Map" resultClass="com.model.ListingObj">
SELECT ACTION_CODE as Code,ACTION_NAME as Description
FROM RECORD_ACTION C
WHERE TYPE = #datatype:VARCHAR#
<isNotNull prepend="AND" property="state">
STATE_CODE = #state:VARCHAR# </isNotNull> </select>


ListingObj class
public class ListingObj {
private String code;
private String description;
public String getCode() { return code; }
public void setCode(String code) { this.code = code; }
public String getDescription() { return description; }
public void setDescription(String description) { this.description = description; }}

No comments: