TypeException: JDBC requires that the JdbcType must be specified for all nullable parameters

mybatis查询报错

报错信息如下:

nested exception is org.apache.ibatis.type.TypeException: JDBC requires that the JdbcType must be specified for all nullable parameters. org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: JDBC requires that the JdbcType must be specified for all nullable parameters. at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:365) at com.sun.proxy.$Proxy71.selectList(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:195) at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:124) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:90) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:40) at com.sun.proxy.$Proxy375.selectByPage(Unknown Source) at

问题原因

原来我的qysxLong属性是string类型的,赋值的时候赋值了一个空字符串,所以报的上面的错,你检查一下是否也是这样的原因

and ((a.qysx =#{qysxLong} and m.actflag = 0) or
(m.actflag = 1))

解决方案

我把qysxLong改成了int类型,并且做了判断,不为0的时候再加这个查询条件

还有一种情况就是像这种,如果proLineList数组的长度为0,也会报上面的错,所以我们需要在多加一个判断
proLineList.size >0,完整版代码如下:

有问题的代码:

and a.qysx in '${proLine}'::int ## 修改后的代码: and a.qysx in '${proLine}'::int

总结

如果你where条件中的字段类型与字段值的类型不匹配,也会报这个错误,多检查一下,希望我的文章可以解决掉你的问题,不懂得或者还是没有解决的私信或留言

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值