MyBatis:統計數量

dao:app

    /**
     * 統計商家的案例數量
     *
     * @param shopId
     * @return
     */
    long countByShopId(Long shopId);
@Override
    public long countByShopId(Long shopId) {
        return super.getSessionTemplate().selectOne(getStatement("countByShopId"), shopId);
    }

mapper:ide

    <select id="countByShopId" parameterType="long" resultType="long">
        SELECT count(1) FROM
        <include refid="t_shop_case"/>
        WHERE shop_id = #{shopId}
    </select>

必定要注意spa

parameterType和
resultType這兩個的類型不能搞錯,否則會出現奇奇怪怪的錯誤!
相關文章
相關標籤/搜索