Skip to main content

Posts

Showing posts from May, 2010

Playing with Ibatis *.*Provider to create dynamic query

Last week, in one of our project, which we decided to upgrade sql queries on ibatis needed dynamic sql query execution. As we decided to use annotations as much as possible on sql mapper - it's seems not a straight to build dynamic query. At first tried to do something as follows: DONOT TRY THIS - IT'S WRONG WAY TO BUILD DYNAMIC QUERY @Update("update ${schemaName}.fdc_uf uf" + " set uf.reestr_date = #{reestDate}," + " uf.reestr_number = #{reestNum}" + " where uf.reestr_number IS NULL AND uf.reestr_date IS NULL and uf.id in " + " <foreach item="item" index="index" collection="list" open="(" separator="," close=")">"+ " #{item}"+ " </foreach>") After some tries, read the user guide attentively, found there are another a few way to build dynamic query, one of them to use Select/Insert/UpdateProvider. These alternative SQL annotations allo...