I would like to know how I can access a HashMap where the definition is HashMap<Integer,ArrayList<Integer[]>>. The ArrayList is a 2-D Integer value {1,1}
<insert id="insertTable" parameterType="hashmap">
INSERT INTO table (col1, col2, col3, col4)
VALUES (
<foreach item="value" collection="map" index="key" open="" separator="),(" close="">
#{key}, #1/31/2016, #{value[0], #{value[1]}--
</foreach>
)
</insert>
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
![]() |
This email has been sent from a virus-free computer protected by Avast. www.avast.com |
file.java:
void insertTab1(@Param("map") HashMap<Integer, ArrayList<Integer[]>> map, @Param("Date") String Date);
file.xml:
<insert id="insertTab1" parameterType="hashmap">
INSERT INTO table1 (id, month, val1, val2)
VALUES (
<foreach item="value" collection="map" index="key" open="" separator="),(" close="">
#{key}, #{Date}, #{value[0]}, #{value[1]}
</foreach>
)
</insert>
Any insight how I can access an array "value" in a HashMap within the xml definition? As mentioned my object will contain a key, value pair with the value being a double array: HashMap: { {1,{1,2}, { 2,{1,2}, ... }.
The #{value[0]} obviously is the wrong syntax.
file.java:
void insertTab1(@Param("map") HashMap<Integer, ArrayList<Integer[]>> map, @Param("Date") String Date);
file.xml:
<insert id="insertTab1" parameterType="hashmap">
INSERT INTO table1 (id, month, val1, val2)
VALUES (
<foreach item="value" collection="map" index="key" open="" separator="),(" close="">
#{key}, #2/18/2016, #{value[0]}, #{value[1]}
</foreach>
)
</insert>
On Monday, February 1, 2016 at 11:59:45 AM UTC-7, Chris F wrote:
Thank you for your response. The HashMap will have 'n' number of values:
HashMap: { {1,{1,2}, { 2,{1,2}, ... }. I have the HashMap working find in my Java app, but when I define the SQL I am not sure how to define the value containing the multiple aray list. The goal is to perform batch inserts using the map collection.
Chris
On Saturday, January 30, 2016 at 10:38:02 PM UTC-7, Chris F wrote:
I would like to know how I can access a HashMap where the definition is HashMap<Integer,ArrayList<Integer[]>>. The ArrayList is a 2-D Integer value {1,1}
<insert id="insertTable" parameterType="hashmap">
INSERT INTO table (col1, col2, col3, col4)
VALUES (
<foreach item="value" collection="map" index="key" open="" separator="),(" close="">
#{key}, #2/18/2016, #{value[0], #{value[1]}
</foreach>
)
</insert>
--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<insert id="insertStats" parameterType="map">
insert into stats
(
hub,
id,
far_id
)
values
(
<foreach item="element" collection="map.entrySet()" index="key" open="" separator="),(" close="">
<foreach item="item" collection="element.value" index="key" open="" separator="),(" close="">
#{element.key}, #{item[0]}, #{item[1]}
</foreach>
</foreach>
)
</insert>
![]() |
0 viruses found. www.avast.com |