使用ibatis将HashMap值插入表中

我在http://old.nabble.com/insert-statement-td21157498.html上找到了这个。我想做同样的事情。我的表中有两列。我可以通过映射hashmap键来插入哈希映射值到列名。现在我想把键值对放在表中,而不管键名。

从上面的链接粘贴。

我想编写一个动态插入语句,但字段和值都是动态的。

我的意思是

 insert into table_one ( !!! dynamic list of keys from the HashMap ) values ( !!! values );  

Hashmap可以是:

  HashMap hm = new HashMap(); hm.put("col1", 1); hm.put("col2", 23); hm.put("col3", 34); 

然后使用hm作为参数调用插入someIDhere。

 insert into table_one ( COLUMN1, COLUMN2, COLUMN3 ) values ( #col1#, #col2#, #col3# );