MyBatis:统计数量
dao:
/** * 统计商家的案例数量 * * @param shopId * @return */ long countByShopId(Long shopId);
@Override public long countByShopId(Long shopId) { return super.getSessionTemplate().selectOne(getStatement("countByShopId"), shopId); }
mapper:
<select id="countByShopId" parameterType="long" resultType="long"> SELECT count(1) FROM <include refid="t_shop_case"/> WHERE shop_id = #{shopId} </select>
一定要注意
parameterType和
resultType这两个的类型不能搞错,不然会出现奇奇怪怪的错误!
弱水_穿云天