保存数据报错 列不存在
### The error occurred while setting parameters
环境:springMVC + MyBatis + Oracle
mabatis-mapper.xml (parameterType="java.util.HashMap")
<insert id="save" parameterType="java.util.HashMap">
<![CDATA[
INSERT INTO ZQ_ACTIVATION(
id,
act_time,
act_unique_id,
act_phone_into,
act_cp_id,
act_system,
act_platform_id,
act_remote_ip,
act_operator
)
VALUES(
ZQ_ACTIVATION_ID_SEQ.NEXTVAL,
#{act_time},
#{act_unique_id},
#{act_phone_into},
#{act_cp_id},
#{act_system},
#{act_platform_id},
#{act_remote_ip},
#{act_operator}
)
]]>
<selectKey keyProperty="ZQ_ACTIVATION.id" resultType="Long"
order="AFTER">
select
ZQ_ACTIVATION_ID_SEQ.CURRVAL AS ID FROM DUAL
</selectKey>
</insert>
service:
public void onProcess(Map<String, Object> map){
this.myDao.save(map);
}
方法调用:
this.zqActivationService.onProcess(map);
代码执行发现报错,经检查发现this.zqActivationService.onProcess(map); 在这里传入的map没有做检查,此处map是有一个jsonObject转换而来
map1:
<span style="color:#ff0000;">{
"act_system":"android 5.1.1",
"act_operator":"1",
...
}</span>
map2:
<pre name="code" class="html">{
act_system=android 5.1.1,
act_operator=1,
...
}
map1是我的参数格式,.此处被mybatis处理报错
解决办法:
改变map格式 改为hashmap
<span style="background-color: rgb(255, 0, 0);">JSONObject jasonObject = JSONObject.fromObject(str2);// String->JSON->Map<String,String>
//将JSONObject 放到HashMap中
Map<String, String> mapObj = new HashMap<>();
Iterator it = jasonObject.keys();
while (it.hasNext()) {
String key = (String)it.next();
mapObj.put(key,jasonObject.get(key).toString());
}</span>