mybatis封装collection时出现异常

_遇见_ 2017-05-19 10:44:02
:封装collection出现如下异常:
Servlet.service() for servlet [mvc] in context with path [] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: Could not set property 'hostlist' of 'class com.cncert.satp.bean.HostVulnerablityBean' with value 'HostScanResultBean{host_result_id=0, host_ip='192.168.100.131', host_port=null, vulnerability='null', tool_name='null', tool_task_id='null', result_id=0, gmt_create=null, gmt_modified=null}' Cause: java.lang.IllegalArgumentException: argument type mismatch] with root cause
java.lang.IllegalArgumentException: argument type mismatch

我写的resultmap如下所示:

<resultMap id="host_list" type="com.cncert.satp.bean.HostVulnerablityBean">
<id column="vulnerability_id" property="vulnerability_id"/>
<result column="host_ip" property="host_ip"/>
<result column="host_port" property="host_port"/>
<result column="vulnerability_name" property="vulnerability_name"/>
<result column="vulenrability_severity" property="vulenrability_severity"/>
<result column="description" property="description"/>
<result column="recommendation" property="recommendation"/>
<result column="cve_no" property="cve_no"/>
<result column="total" property="total"/>
<association property="cnvdVulnerabilityBean" javaType="com.cncert.satp.bean.CNVDVulnerabilityBean">
<id column="loudongid" property="loudongid"/>
<result column="loophole_name" property="loophole_name"/>
</association>
<collection property="hostlist" javaType="com.cncert.satp.bean.HostScanResultBean">
<id column="host_result_id" property="host_result_id" jdbcType="INTEGER"/>
<result column="host_ip" property="host_ip" jdbcType="VARCHAR"/>
</collection>
</resultMap>


<select id="getHostVulDetail" parameterType="int" resultMap="host_list">
select host_vulnerability.vulnerability_name,
host_vulnerability.vulenrability_severity,
host_vulnerability.description,
host_vulnerability.recommendation,
host_vulnerability.cve_no,
host_result.host_ip,
cnvd_loophole.cnvd_id as loudongid,
cnvd_loophole.loophole_name,
cnvd_loophole.severity as cnvd_severity ,
cnvd_loophole.description as cnvd_description,
cnvd_loophole.solution as cnvd_solution,
cnvd_loophole.vulenrability_no,
cnvd_loophole.pub_date,
cnvd_loophole.vulenrability_source,
cnvd_loophole.impact,
cnvd_loophole.cnvd_id,
cnvd_loophole.cve_id,
cnvd_loophole.vulenrability_type,
cnvd_loophole.url,
cnvd_loophole.reference_link,
cnvd_loophole.discoverer,
cnvd_loophole.patch,
cnvd_loophole.verification_info,
cnvd_loophole.report_date,
cnvd_loophole.record_date,
cnvd_loophole.update_date
from host_result
inner join host_vulnerability
on host_result.vulnerability=host_vulnerability.vulnerability_name
inner join scan_result
on host_result.result_id=scan_result.result_id
left join cnvd_loophole
on cnvd_loophole.cve_id=host_vulnerability.cve_no
where scan_result.task_id=#{taskid}
order by host_vulnerability.vulnerability_name
</select>

host_vulnerability是主机漏洞,host_result是主机扫描结果,主机漏洞bean里边有List<主机扫描结果>。我现在想要把主机扫描结果用collection封装,但是一直出现上面的异常。在网上搜索说是因为join的时候时无序的,必须手动排序后才可以。我试着排序了还是不行。求各位大神指教。
之前参考这个进行改的:http://www.cnblogs.com/zemliu/archive/2013/08/16/3263053.html
...全文
470 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
_遇见_ 2017-05-19
  • 打赏
  • 举报
回复
1楼说的问题我想过,加上之后还是不行 这是HostVulnerablityBean里中hostlist的类型 private List<HostScanResultBean> hostlist;
famousboy 2017-05-19
  • 打赏
  • 举报
回复
HostVulnerablityBean 里面 hostlist 这个属性定义的什么类型?
李德胜1995 2017-05-19
  • 打赏
  • 举报
回复
HostVulnerablityBean贴出来看看。。。
baolongf 2017-05-19
  • 打赏
  • 举报
回复
select中没有 host_result_id

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧