java接口方法:
public int getCount(ProjectCriteria criteria);ProjectCriteria类:只有String name属性
<select id="getCount" parameterType="ProjectCriteria" resultType="int"> select count(1) from project where `name` like '%#{name,jdbcType=VARCHAR}%' </select>junit报错:
配置什么的都没问题,其他项目也这样用,同一个项目中insert,update方法都好着呢,就select这个方法里边不能用,不知道为什么
报错是类型异常,但是String 不就对应jdbcType的VARCHAR吗?
resultType="int">改成resultClass="java.lang.Integer"
试了,并不是这里的问题<spanstyle="font-family:Consolas,'BitstreamVeraSansMono','CourierNew',Courier,monospace;font-size:14px;background-color:#FFFFFF;">jdbcType=VARCHAR<divclass="linenumber1index0alt2"><selectid="getCount"parameterType="ProjectCriteria"resultType="int">回复<aclass='referer'target='_blank'>@匆匆z2:我写的都不用呢,一切正常你的意思是不用jdbcType,我之前是写在mybatis判断语句里边的,后来报错就直接这样写方便点了,官方文档里边的说法是,对于可能为空的类型需要给出jdbcType,如果为空的话,这样就不行了,去掉之后还是报错555<divclass='ref'>
<spanstyle="font-size:14px;line-height:24px;background-color:#F8FEEE;">已经解决了,参数会自带引号
<spanstyle="color:#333333;font-family:'MicrosoftYaHei';font-size:14px;line-height:24px;background-color:#F8FEEE;">where name<spanstyle="color:#333333;font-family:'MicrosoftYaHei';font-size:14px;line-height:24px;background-color:#F8FEEE;"> like“%"#{name,jdbcType=VARCHAR}"%"
parameterType写错了吧<spanstyle="font-family:Consolas,'BitstreamVeraSansMono','CourierNew',Courier,monospace;font-size:14px;line-height:15.4px;background-color:#FFFFFF;">wherename
like'%'||#{name,jdbcType=VARCHAR}||'%'
namelike'%${<spanstyle="font-family:Consolas,'BitstreamVeraSansMono','CourierNew',Courier,monospace;font-size:14px;line-height:15.390625px;background-color:#FFFFFF;">name}%'
<spanstyle="font-family:Consolas,'BitstreamVeraSansMono','CourierNew',Courier,monospace;font-size:14px;line-height:15.390625px;background-color:#FFFFFF;">namelike'%'||#{name,jdbcType=VARCHAR}||'%'
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。