Problem:
I needed to verify if each record passed several rules, where each rule consisted of several flags and their values. The problem was complexity: I had 7 flags(which had 3 possible values) to check, and 1 to 5 rules per status. This could lead to some ugly and hard to test SQL.
Another problem was that you cant iterate over multiple lists at the same time (using the same index) in ibatis.
Solution:
The solution was to use Ibatis's Iterate directive. I would iterate over lists of maps, where each map represented a rule, and each bucket of the map represented a flag and its expected value.
Those iBastis code ended up looking something like this:
and the parameter class had the following code:
This worked pretty well to abstract the flags and rules away from the iBatis sql and keep them all in the rules class.