Hello Rahul,

I am very new to Ibatis so I need some help in regard to, How I can register my ArrayToStringtypehandlercallback for a particular field.


1) I know that I can declare my typehandler in sqlmapConfig file but if I do so, that means declaring it for every parameter of the same type , i.e globally , which I do not want as it would result in my typehandler being called every time when it would encounter that type in any other parameter class ( please correct me if I am wrong or will it will be called only where I actually specify it like in inline parameters I am doing in my sqlmap resource file? And do not register this in my SQL-MAP-CONFIG.xml).


<typeAlias alias="IntArrayTypeHandler" type="com.asci.common.ibatis.IntArrayTypeHandler" />
2) what is the syntax for declaring my typehandler locally ?

<select id="selectByIds" parameterClass="map" resultMap="result" >
        SELECT
        <include refid="selectFragment"/>
        FROM dispovariante AS dv
        WHERE dv.id = ANY (#ids,handler=IntArrayTypeHandler#)
</select>

In the DAO write something like

public List<Dispovariante> selectByIds(Set<Integer> ids)
{
        HashMap<String, Object> params = new HashMap<String, Object>();
        params.put("ids", ids);
        List<Dispovariante> list = getSqlMapClientTemplate().queryForList(
                "dispovariante.selectByIds", params);
        return list;
}

Ingmar

Reply via email to