【无标题】

在执行聚合查询时遇到错误,问题源于ResultMap配置。XML文件中引用了hostPowerResultMap,但在ResultMaps集合中未找到对应值。解决方案是确保类的属性和数据库列名映射正确,或者将缺失的ResultMap配置放入当前XML中。
摘要由CSDN通过智能技术生成

聚合查询的时候报错

Cause: java.lang.IllegalArgumentException: Result Maps collection does not contain value for com.sxt.mapper.HostMapper.hostPowerResultMap
java.lang.IllegalArgumentException: Result Maps collection does not contain value for com.sxt.mapper.HostMapper.hostPowerResultMap

xml文件

<resultMap id="hostResultMap" type="com.sxt.pojo.Host">
        <id column="hid" property="hid" />
        <result column="hname" property="hname" />
        <result column="hpwd" property="hpwd" />
        <result column="hphone" property="hphone" />
        <result column="starttime" property="starttime" />
        <result column="status" property="status" />
        <result column="strong" property="strong" />
        <result column="ordernumber" property="ordernumber" />
        <association property="hostPower" javaType="com.sxt.pojo.HostPower" resultMap="hostPowerResultMap" autoMapping="true">
<!--        <id column="hpid" property="hpid"/>-->
<!--            <result column="hpstar" property="hpstar" />-->
<!--            <result column="hpstart_begindate" property="hpstartBegindate" />-->
<!--            <result column="hpstar_enddate" property="hpstarEnddate" />-->
<!--            <result column="hp_order_power" property="hpOrderPower" />-->
<!--            <result column="hpstar_begintime" property="hpstarBegintime" />-->
<!--            <result column="hpstar_endtime" property="hpstarEndtime" />-->
<!--            <result column="hpdiscount" property="hpdiscount" />-->
<!--            <result column="hp_dis_starttime" property="hpDisStarttime" />-->
<!--            <result column="hp_dis_endtime" property="hpDisEndtime" />-->
<!--            <result column="hpprice" property="hpprice" />-->
<!--            <result column="hpcosts" property="hpcosts" />-->
<!--            <result column="hostid" property="hostid" />-->
        </association>
    </resultMap>
    <select id="selHostInfo" resultMap="hostResultMap">
        select * from t_host h left join t_host_power p
        on h.hid = p.hostid
        <where>
            <if test="hostCondition.hname!='' and hostCondition.hname != null" >
                and h.hname like concat('%',#{hostCondition.hname},'%')
            </if>
            <if test="hostCondition.status != '' and hostCondition.status != null">
                and h.status = #{hostCondition.status}
            </if>
            <if test="hostCondition.hpstar != '' and hostCondition.hpstar != null">
                and p.hpstar = #{hostCondition.hpstar}
            </if>
            <if test="hostCondition.hpdiscount != '' and hostCondition.hpdiscount != null">
                and p.hpdiscount = #{hostCondition.hpdiscount}
            </if>
        </where>
        order by h.strong
        <if test="hostCondition.strong != '' and hostCondition.strong != null">
            ${hostCondition.strong}
        </if>
    </select>
    <resultMap id="hostPowerResultMap" type="com.sxt.pojo.HostPower">
        <id column="hpid" property="hpid" />
        <result column="hpstar" property="hpstar" />
        <result column="hpstart_begindate" property="hpstartBegindate" />
        <result column="hpstar_enddate" property="hpstarEnddate" />
        <result column="hp_order_power" property="hpOrderPower" />
        <result column="hpstar_begintime" property="hpstarBegintime" />
        <result column="hpstar_endtime" property="hpstarEndtime" />
        <result column="hpdiscount" property="hpdiscount" />
        <result column="hp_dis_starttime" property="hpDisStarttime" />
        <result column="hp_dis_endtime" property="hpDisEndtime" />
        <result column="hpprice" property="hpprice" />
        <result column="hpcosts" property="hpcosts" />
        <result column="hostid" property="hostid" />
    </resultMap>

解决
需要将类的变量和列名转换放在内(注释内),或者将另一个类的转换放在当前xml的内

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值