Translate

Saturday, January 21, 2012

MyBatis Dynamic Table Name

There may be times when you need to dynamically specify the name of the table you're accessing. In my case I have a few look-up tables with the same structure. I did it like this:

<select id="getKeyValue" resultMap="KeyValueMap" parameterType="java.lang.String">
    select ID, Value from ${value}
</select>

The only parameter is the name of the table. You can see  another nice example at Dynamic MyBatis.

1 comment:

Thank you for commenting!