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这两个的类型不能搞错,不然会出现奇奇怪怪的错误!
posted @ 2016-09-19 15:54  园芳宝贝  阅读(13453)  评论(0编辑  收藏  举报