I meet a problem about ibatis' dynamic sql mapping. My db query is implemented by store procedure, and this procedure will go to sub procedure A or B depends on some condition. Now here comes the problem, sub procedure A will return column "price_category" and it will be mapped to property "priceCategory" by ibatis' resultMap, however sub procedure B will not return column "price_category" and ibatis will throw exception since mapping can not be done. So my thinking is to resolve this by dynamic mapping, which means ibatis will set "priceCategory" to null in resultMap if sql doesn't return column "price_category". Could this be implemented by some config tricks in ibatis? I think ibatis should have been able to do this however I didn't find related information in other places. Could you give me some points on this? Thanks guys.

1

There are 1 best solutions below

0
On

You could have procedure B return a dummy column with null values. For example:

select a, b, c, null as priceCategory from myTable
// rest of your procedure code here