当配置mybatis返回int类型时 select id="getUserIdByName" parameterType="string" resultType="int"> SELECT id FROM user WHERE userName = #{userName} </select> 会报错如下: org.springframework.web.util.NestedServletException: Request p
mybatis将传入的Integer类型的0被识别成空字符串,网上的解决办法: <if test="status != null and status != '' or status == 0"> and status = #{status, jdbcType = INTEGER}</if> 然而还是有无效的时候.既然status==''时无效,就将其置为null.此时就在Java中对该参数进行处理,当 status == '' 时将其赋值为 null. @Po
重点:select * from course where cast(courseId as char) like '%118%'; 首先可以将int类型转换为string类型的值再进行模糊查询,用方法cast(num as char):这个可以将num(int类型)转化为char类型.完整的语句:假如我现在要在课程表(course)里面根据课程id(courseId)进行模糊查询:select * from course where cast(courseId as char) like '%