mybatis抛出以下异常:

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.lang.UnsupportedOperationException
### The error may exist in com/drs/mapper/AppointmentMapper.xml
### The error may involve com.drs.mapper.AppointmentMapper.appointTime
### The error occurred while handling results
### SQL: select id from tb_time where id not in(select time_id from tb_reservation         where car_id=? and appointmentDate=?);
### Cause: java.lang.UnsupportedOperationException

Error querying database. Cause: java.lang.UnsupportedOperationException

对应语句如下:

<select id="appointTime" resultType="List" parameterType="map">
        select id from tb_time where id not in(select time_id from tb_reservation
        where car_id=#{car_id} and appointmentDate=#{appointmentDate});
    </select>

错误原因是 resultType=“List” ,这里应该改成: resultType=“java.lang.Integer”

<select id="appointTime" resultType="java.lang.Integer" parameterType="map">
        select id from tb_time where id not in(select time_id from tb_reservation
        where car_id=#{car_id} and appointmentDate=#{appointmentDate});
    </select>

这里 resultType 指的是 select 返回的每一条记录 的类型(单个值),而不是所有记录组成的类型。

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐