mybatis开发中遇到的一些问题

1、遇到tinyint类型的字段,查询返回时自动变Boolean类型,最好办法是改类型,如smallint。

2、sum() 返回返回值在mybatis中是作为BigDecimal来返回的,处理:
(1)返回 Object 值,通过 Integer.parseInt(object.toString()); 得到int值;
(2)返回 BigDecimal 值,通过 BigDecimal.intValue()获得值。

3、mybatis把整数0(类字段属性定义)识别为null  我们可以在if条件中判断中添加:

<if test="status != null and status != ''  or status == 0" >
		and mea.status = #{status}
</if>

 另一种办法是将字段类型定义成String型。

猜你喜欢

转载自wwy0612.iteye.com/blog/2374329