alibaba / druid

阿里云计算平台DataWorks(https://help.aliyun.com/document_detail/137663.html) 团队出品,为监控而生的数据库连接池
https://github.com/alibaba/druid/wiki
Apache License 2.0
27.95k stars 8.57k forks source link

在resultMap的collection中使用select查询传递日期类型的参数时,报错 java.sql.SQLFeatureNotSupportedException #5263

Closed moonce closed 11 months ago

moonce commented 1 year ago

引入版本

 <!--阿里 Druid Spring Boot Starter依赖-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>1.1.24</version>
        </dependency>
  <!--MyBatis 及 插件依赖-->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.3.0</version>
        </dependency>

错误描述

在resultMap的collection中使用select查询传递日期类型的参数时,报以下错误

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column 'plan_time' from result set.  Cause: org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column 'plan_time' from result set.  Cause: java.sql.SQLFeatureNotSupportedException
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:96)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441)
    at com.sun.proxy.$Proxy124.selectList(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224)
    at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:147)
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:80)
    at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:145)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:86)

Mapper

   <resultMap id="BaseResultMap" type="com.xxx.model.A">
        <!--
          WARNING - @mbg.generated
        -->
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="status" jdbcType="TINYINT" property="status"/>
        <result column="plan_time" jdbcType="TIMESTAMP" property="planTime"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
        <result column="remark" jdbcType="VARCHAR" property="remark"/>
    </resultMap>
    <resultMap id="OtherMap" type="com.xxx.model.B">
        <!--
          WARNING - @mbg.generated
        -->
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="status" jdbcType="TINYINT" property="status"/>
        <result column="plan_time" jdbcType="TIMESTAMP" property="planTime"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
        <result column="remark" jdbcType="VARCHAR" property="remark"/>
    </resultMap>
    <resultMap id="BaseResultDtlMap" type="com.xxx.pojo.ADTO" extends="BaseResultMap">
        <collection property="bList" ofType="com.xxx.model.B" column="{planTime=plan_time}" select="selectB" />
    </resultMap>
    <select id="selectList"
            resultMap="BaseResultDtlMap">
        select id,plan_time from a
    </select>
    <select id="selectB"
            resultMap="OtherMap">
        select * from b
        where #{planTime}
    </select>
lizongbo commented 1 year ago

druid 1.1.24这个版本过低,这个bug早就修复了,请使用最新版druid。

wenshao commented 11 months ago

https://github.com/alibaba/druid/releases/tag/1.2.20 请用新版本