使用MyBatis时出现java.lang.IndexOutOfBoundsException: Index: 1, Size: 1

mapper xml 查询时报错

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
### The error may exist in file [C:\Users\56342\Desktop\irest\irest-reports\irest-reports-server\target\classes\com\shht\irest\reports\server\mapper\oms\xml\OrderTransactionMapper.xml]
### The error may involve com.shht.irest.reports.server.mapper.oms.OrderTransactionMapper.countConsumeCount
### The error occurred while handling results
### SQL: SELECT         COUNT(DISTINCT(ot.id)) as `count`         FROM         oms_order_transaction ot         JOIN         oms_order_transaction_detail otd ON ot.id = otd.transaction_id         WHERE         ot.tenant_id = 1         AND ot.pay_time BETWEEN ? AND ?         AND ot.type = 'CONSUME' and ot.state = 'SUCCESS' AND ot.delete_flag = 0                       AND otd.merchant_id = ?
### Cause: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:92)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:440)
	at com.sun.proxy.$Proxy124.selectOne(Unknown Source)
	at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:159)
	at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:90)
	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148)
	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89)
	at com.sun.proxy.$Proxy128.countConsumeCount(Unknown Source)

对应的sql 语句

 select


        dispute.case_type caseType,
        zhuandi.create_time createTime,
        zhuandi.dispute_id disputeId,
        zhuandi.innertdeptcode,
        zhuandi.innertdept,
        zhuandi.zhuandi_status zhuandiStatus,
        '' zhuandiStatusTxt,
        zhuandi.zddwcode,
        zhuandi.zddw,
        dispute.case_time caseTime,
        dispute.case_address caseAddress,
        dispute.case_person casePerson,
        dispute.case_phone casePhone,
        dispute.case_content caseContent,
        dispute.case_code caseCode,
        dispute.parent_region_name parentRegionName,
        dispute.region_name regionName,
        dispute.region_code regionCode,
        dispute.zrqmc,
        dispute.zrqdm,
        dispute.pcsdm,
        dispute.pcsmc,
        dispute.cszrqmc,
        dispute.cszrqdm



        FROM dispute_forward zhuandi
        LEFT JOIN dispute on dispute.id=zhuandi.dispute_id and dispute.del_flag=0 and zhuandi.deleted=0

        WHERE 1=1  AND zhuandi.zhuandi_lx = '1'
        <if test="startTime != null and startTime != ''">
            AND zhuandi.create_time &gt;= #{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
            AND zhuandi.create_time &lt;= #{endTime}
        </if>

        <if test="zrqdm != null and zrqdm != ''">
            and zhuandi.innertdeptcode like concat(#{zrqdm}, '%')
        </if>

        <if test="zhuandiStatus != null and zhuandiStatus != ''">
           and zhuandi.zhuandi_status = #{zhuandiStatus}
        </if>

        <if test="caseCode != null and caseCode != ''">
            AND case_code like concat( '%',#{caseCode}, '%')
        </if>
        <if test="casePhone != null and casePhone != ''">
            AND case_phone like concat('%',#{casePhone}, '%')
        </if>

        <if test="casePerson != null and casePerson != ''">
            AND case_person like concat('%',#{casePerson}, '%')
        </if>

        <if test="caseAddress != null and caseAddress != ''">
            AND case_address like concat('%',#{caseAddress}, '%')
        </if>
        AND zhuandi.zhuandi_status in (0,1)
        order by zhuandi.create_time desc

出现场景:在使用MyBatis进行SQL查询的时候,会抛出异常java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
出现原因:项目中Mapper查询结果映射的Result实体类没有提供无参构造器
解决方法:映射的实体类加上@NoArgsConstructor

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class DisputeZhuanDiVO
{

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值