0

The map type is unordered, but I tested hundreds of data without any confusion

xml like this:

        insert into AA
        <foreach collection="map.keySet()" item="key" separator="," open="(" close=")">
            ${key}
        </foreach>
        values
        <foreach collection="map.values()" item="val" separator="," open="(" close=")">
            #{val}
        </foreach>

interface code like this:

       int insertHT(@Param("map") Map<String, Object> map);

map is {"aa":"11","bb":"22"}

insertHT,I have performed this 100 times

I don't know whether this is correct or whether the data will always be inserted correctly

kert
  • 1
  • 1
  • See this [answer](https://stackoverflow.com/a/1882804/1261766). If the order matters, you must use `LinkedHashMap` or `TreeMap` depending on your requirement (or some 3rd party implementation). I mentioned it in this [answer](https://stackoverflow.com/a/68216214/1261766). – ave Mar 01 '23 at 11:10
  • That's great I'll do it – kert Mar 01 '23 at 16:41

0 Answers0