MyBatis - How to write <if> statement under <foreach>?
Asked Answered
M

1

7

I loop a collection, and only when the item of the collection is not null, then it will be inserted into the DB, the snippet code like that:

<foreach collection="ids" item="id" separator=",">
    <if test="id!= null">
       (#{id})
    </if>
</foreach>

the statement run failed, it said "Parameter 'id' not found.", the I change the statement :

<if test="#{id}!= null">

It failed also, so how can I write the statement?

Mneme answered 5/8, 2015 at 3:26 Comment(0)
M
3

Update the version from 3.2.8 to 3.3.0, it will be fixed.

Mneme answered 5/8, 2015 at 6:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.