ibatise 动态查询int型条件null值时自动变0

来源:百度知道 编辑:UC知道 时间:2024/06/22 19:16:18
<select id="newsByPage" resultMap="newsVoResult" parameterClass="newsVO" >
select top $paginationCount$ * from news where id not in
(
select top $paginationStart$ id from news
order by id desc
)

<isNotNull property="title" prepend="AND"
removeFirstPrepend="true">
title like '%$title$%'
</isNotNull>
<isNotNull property="shopid" prepend="AND"
removeFirstPrepend="true">
shopid ='$shopid$'
</isNotNull>
<isNotNull property="carid" prepend="AND"
removeFirstPrepend="true">
carid ='$carid$'
</isNotNull>
order by id desc
</select>
这里边的 carid 从页面进入方法时,过来时不给值的话应该是null, 而到查询这竟然自动成0了,也就是查询条件是carid=0 的数据,为什么?
应该是null 的怎么成0了?

carid 是int 型的。 是不是

newsVO.java里面的carid 属性是int类型的吧!
我猜如果换成Integer类型或其他的数值类型的类应该可以。
因为int是基本类型,不属于类,不赋值时默认值就是0。

重装系统