**如果我们报以下代码错误请看好报错代码是否一致如果一致请继续往下看**
org.apache.ibatis.binding.BindingException: Mapper method 'com.jk.zs.dao.booksDao.queryUCount attempted to return null from a method with a primitive return type (int)`
**报错如下图标记路径和错误地址**
**正确写法如下图**
**展示如下**
**请注意每个类型的应设置的类型以下代码仅供参考大神勿喷**
<!-- 查询用户表的总条数 -->
<select id="queryUCount" resultType="int">
select count(1) from t_user t
<include refid="userSql"></include>
</select>
<!-- 查询用户表的总条数 -->
<select id="queryUserPage" resultType="com.jk.wdd.pojo.UserBean">
select b.* from
(select a.*,rownum rn from
(select t.user_id userId,t.user_name userName,t.user_pwd userPwd,t.user_age userAge,t.user_sex userSex,
to_char(t.user_birth,'yyyy-mm-dd') userBirth,t.user_img userImg,p.type_name typeName,t.user_info userInfo,d.text deptName from t_user t
left join t_type p on t.type_id = p.type_id
left join t_dept d on t.dept_id = d.id
<include refid="userSql"></include>)a
where rownum<=#{end})b
where b.rn >#{start}
</select>
<!-- 公共sql -->
<sql id="userSql">
<where>
<if test="user.userName!=null and user.userName!=''">
and t.user_name like '%${user.userName}%'
</if>
<if test="user.userSex!=null and user.userSex!=-1">
and t.user_sex = #{user.userSex}
</if>
<if test="user.typeId!=null">
and t.type_id = #{user.typeId}
</if>
</where>
</sql>
<!-- 查询所有的用户类型 -->
<select id="queryType" resultType="com.jk.wdd.pojo.TypeBean">
select p.type_id typeId,p.type_name typeName from t_type p
</select>
<!-- 删除用户 -->
<delete id="deleteUser" parameterType="string">
delete t_user t where t.user_id in
<foreach collection="array" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</delete>
<!-- 新增用户 -->
<insert id="addUser" parameterType="com.jk.wdd.pojo.UserBean">
insert into t_user values(seq_user.nextval,#{userName},#{userPwd},#{userAge},#{userSex},to_date(#{userBirth},'yyyy-mm-dd'),#{typeId},#{userImg},#{userInfo},#{deptId})
</insert>
<!-- 修改:回显 -->
<select id="queryUserById" parameterType="int" resultType="com.jk.wdd.pojo.UserBean">
select t.user_id userId,t.user_name userName,t.user_pwd userPwd,t.user_age userAge,t.user_sex userSex,
to_char(t.user_birth,'yyyy-mm-dd') userBirth,t.user_img userImg,t.type_id typeId,t.user_info userInfo,t.dept_id deptId from t_user t
where t.user_id = #{userId}
</select>
<!-- 修改 -->
<update id="updateUser" parameterType="com.jk.wdd.pojo.UserBean">
update t_user t set t.user_name =#{userName},t.user_pwd=#{userPwd},t.user_age=#{userAge},
t.user_sex=#{userSex},t.user_birth=to_date(#{userBirth},'yyyy-mm-dd'),t.type_id=#{typeId},
t.user_img=#{userImg},t.user_info = #{userInfo},t.dept_id=#{deptId}
where t.user_id=#{userId}
</update>
<!-- 验证用户名 -->
<select id="queryUserName" parameterType="string" resultType="com.jk.wdd.pojo.UserBean">
select t.user_name userName,t.user_pwd userPwd,t.user_id userId from t_user t where t.user_name=#{userName}
</select>
<insert id="zhuceuser" parameterType="com.jk.wdd.pojo.UserBean">
insert into t_user t (t.user_id,t.user_name,t.user_pwd)values(seq_user.nextval,#{userName},#{userPwd})
</insert>
<!-- 修改性别 -->
<update id="updateSex" parameterType="com.jk.wdd.pojo.UserBean">
update t_user t set t.user_sex = #{userSex} where t.user_id = #{userId}
</update>
<!-- 根据pid查询部门的子节点 -->
<select id="queryDeptByPid" parameterType="int" resultType="com.jk.wdd.pojo.DeptBean">
select * from t_dept d where d.pid = #{pid}
</select>
</mapper>