Archive for March, 2009

IN operator in iBatis

March 12, 2009

Another confusion will occur while working with iBatis , when we need to do something like

where id in (100,101,102)

We can simply do it as like this.

where r.status = ‘A’
<dynamic >
<isNotNull property=”Clients”>
and c.id
<iterate property=”Clients” open=”IN (” close=”)” conjunction=”,”>
#Clients[]#
</iterate>
</isNotNull>
<isNotNull property=”SMT”>
and t.smt_id
<iterate property=”SMT” open=”IN (” close=”)” conjunction=”,”>
#SMT[]#
</iterate>
</isNotNull>
</dynamic>

where SMT and Clients are lists, which can be any lists,  that I put into the parameter map(here am passing java.util.HashMap as parameter map).

Logging in Ibatis

March 12, 2009

It will be too useful if you enable loggin in iBatis. Developers can use it extensively for debugging. Just add these lines at log4j.xml and Bingo!!! you will start getting logs for each ibatis and sql threads in  your system.

<logger name=”com.ibatis” additivity=”false”>
<level value=”debug”/>
<appender-ref ref=”PIPELINE”/>
</logger>

<logger name=”java.sql” additivity=”false”>
<level value=”debug”/>
<appender-ref ref=”PIPELINE”/>
</logger>

<logger name=”org.springframework” additivity=”false”>
<level value=”info”/>
<appender-ref ref=”PIPELINE”/>
</logger>

where PIPELINE is the appender name I declared in the log4j.xml.

Tail Note : Don’t forget to remove iBatis logging when your system moves to production. The log file size will become more than 10 MB in 10 minutes of usage. 🙂


%d bloggers like this: