写了一个下面的SQL,用来check time 在表中存不存在的:
<select id="checkTimeExist" resultType="int">
SELECT
1
FROM
dual
WHERE
EXISTS (
SELECT
1
FROM
`performance` AS p
WHERE
p.`stat_time` = #{time}
)
</select>
我把返回值设为了 resultType=”int” ,结果在查询不到结果时,报了下面的异常:
org.apache.ibatis.binding.BindingException: Mapper method 'com.test.persistence.PerformanceMapper.checkTimeExist attempted to return null from a method with a primitive return type (int).
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:83) ~[mybatis-3.4.0.jar:3.4.0]
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53) ~[mybatis-3.4.0.jar:3.4.0]
at com.sun.proxy.$Proxy38.checkTimeExist(Unknown Source) ~[?:?]
...
看来就只能把 返回值 类型 改成 Integer 来解决这个问题了。