mybatis 查询 resultMap="" 只返回一条数据

在已确认sql没问题的情况下

检查查询的字段  是否与resultMap 标签中的参数相匹配

如下图修改前:

<resultMap id="BaseResultMap" type="com.koow.kkwwo.pojo.To_pay" >
    <id column="to_pay_id" property="toPayId" jdbcType="INTEGER" />
    <result column="to_pay_orderId" property="toPayOrderid" jdbcType="VARCHAR" />
    <result column="to_pay_money" property="toPayMoney" jdbcType="DECIMAL" />
    <result column="to_pay_on_date" property="toPayOnDate" jdbcType="TIMESTAMP" />
    <result column="to_pay_end_date" property="toPayEndDate" jdbcType="TIMESTAMP" />
    <result column="to_pay_state" property="toPayState" jdbcType="INTEGER" />
    <result column="to_pay_fee" property="toPayFee" jdbcType="INTEGER" />
    <result column="user_id" property="userId" jdbcType="INTEGER" />
    <result column="to_pay_asynchronous_address_df" property="toPayAsynchronousAddressDf" jdbcType="VARCHAR" />
    <result column="to_pay_money_state" property="toPayMoneyState" jdbcType="INTEGER" />
    <result column="to_pay_money_state2" property="toPayMoneyState2" jdbcType="INTEGER" />
    <result column="to_pay_money_state3" property="toPayMoneyState3" jdbcType="INTEGER" />
    <result column="to_pay_sy_message1" property="toPaySyMessage1" jdbcType="VARCHAR" />
    <result column="to_pay_sy_message2" property="toPaySyMessage2" jdbcType="VARCHAR" />
    <result column="to_pay_sy_message3" property="toPaySyMessage3" jdbcType="VARCHAR" />
    <result column="to_pay_sy_message4" property="toPaySyMessage4" jdbcType="VARCHAR" />
    <result column="to_pay_accNo" property="toPayAccno" jdbcType="VARCHAR" />
    <result column="to_pay_accName" property="toPayAccname" jdbcType="VARCHAR" />
    <result column="to_pay_banktype" property="toPayBanktype" jdbcType="VARCHAR" />
    <result column="to_pay_bank_zh_name" property="toPayBankZhName" jdbcType="VARCHAR" />
    <result column="passageway_id" property="passagewayId" jdbcType="INTEGER" />
    <collection property="passageways" javaType="java.util.List" ofType="com.koow.kkwwo.pojo.Passageway">  
            <id column="passageway_id" property="passagewayId" jdbcType="INTEGER" />  
            <result column="passageway_des" property="passagewayDes" jdbcType="VARCHAR" />  
            <result column="passageway_chid" property="passagewayChid" jdbcType="INTEGER" />  
    </collection> 
  </resultMap>

<select id="selectBy_to_pay_state_date" resultMap="BaseResultMap" parameterType="com.koow.kkwwo.pojo.To_pay" >
    select  tp.to_pay_orderId,tp.to_pay_sy_message1,tp.passageway_id,tp.to_pay_money,tp.to_pay_fee,tp.user_id,pa.*
    from to_pay tp left join passageway pa on  tp.passageway_id=pa.passageway_id
    where to_pay_state = #{toPayState,jdbcType=INTEGER} and to_pay_on_date > #{toPayOnDate,jdbcType=VARCHAR} and to_pay_sy_message4  is not null and to_pay_sy_message4!=''
  </select>




修改后:

<resultMap id="ToPayStateDate" type="com.koow.kkwwo.pojo.To_pay" >
    <result column="to_pay_orderId" property="toPayOrderid" jdbcType="VARCHAR" />
    <result column="to_pay_money" property="toPayMoney" jdbcType="DECIMAL" />
    <result column="to_pay_fee" property="toPayFee" jdbcType="INTEGER" />
    <result column="user_id" property="userId" jdbcType="INTEGER" />
    <result column="to_pay_sy_message1" property="toPaySyMessage1" jdbcType="VARCHAR" />
    <result column="passageway_id" property="passagewayId" jdbcType="INTEGER" />
    <collection property="passageways" javaType="java.util.List" ofType="com.koow.kkwwo.pojo.Passageway">  
            <id column="passageway_id" property="passagewayId" jdbcType="INTEGER" />  
            <result column="passageway_des" property="passagewayDes" jdbcType="VARCHAR" />  
            <result column="passageway_chid" property="passagewayChid" jdbcType="INTEGER" />  
    </collection> 
  </resultMap>
<select id="selectBy_to_pay_state_date" resultMap="ToPayStateDate" parameterType="com.koow.kkwwo.pojo.To_pay" >
    select  tp.to_pay_orderId,tp.to_pay_sy_message1,tp.passageway_id,tp.to_pay_money,tp.to_pay_fee,tp.user_id,pa.*
    from to_pay tp left join passageway pa on  tp.passageway_id=pa.passageway_id
    where to_pay_state = #{toPayState,jdbcType=INTEGER} and to_pay_on_date > #{toPayOnDate,jdbcType=VARCHAR} and to_pay_sy_message4  is not null and to_pay_sy_message4!=''
  </select>


猜你喜欢

转载自blog.csdn.net/u012934723/article/details/77879910