MyBatis iterate hashmap with foreach -
i have small problem mybatis. i'm trying iterate on hashmap seems, mybatis not able it. name of hshmap servicemap. here code of mybatis foreach:
<foreach item="item" index="key" collection="servicemap" open="(" separator="or" close=")"> (upper(p.endpoint) upper(#{key}) , upper(p.endpoint_operation) upper(#item)) </foreach>
the exception is:
org.apache.ibatis.builder.builderexception: error evaluating expression 'servicemap'. return value ({vehicle=register}) not iterable. @ org.apache.ibatis.builder.xml.dynamic.expressionevaluator.evaluateiterable(expressionevaluator.java:59) @ org.apache.ibatis.builder.xml.dynamic.foreachsqlnode.apply(foreachsqlnode.java:51) @ org.apache.ibatis.builder.xml.dynamic.mixedsqlnode.apply(mixedsqlnode.java:29) @ org.apache.ibatis.builder.xml.dynamic.ifsqlnode.apply(ifsqlnode.java:31) @ org.apache.ibatis.builder.xml.dynamic.mixedsqlnode.apply(mixedsqlnode.java:29)
is mybatis not able or did make mistake?
it nice, if can me.
thanks lot! stefan
a hashmap not iterable. you need iterate entryset.
<foreach item="item" index="key" collection="servicemap.entryset" open="(" separator="or" close=")"> (upper(p.endpoint) upper(#{key}) , upper(p.endpoint_operation) upper(#item))
Comments
Post a Comment