spring中@paramhtml
/** * 查詢指定用戶和企業關聯有沒有配置角色 * @param businessId memberId * @return */ int selectRoleCount(@Param("businessId") Integer businessId,@Param("memberId") Long memberId);
/** * 查詢指定用戶和企業關聯有沒有配置角色 * @param businessId memberId * @return */ int selectRoleCount(@Param("businessId") Integer businessId,@Param("memberId") Long memberId);
<select id="selectRoleCount" resultType="java.lang.Integer" > select count(tbm.id) from t_business_member_relation tbm where tbm.business_id = #{0,jdbcType=INTEGER} and tbm.member_id = #{1,jdbcType=INTEGER} and tbm.role_business_id is not null </select>
<select id="selectRoleCount" resultType="java.lang.Integer" > select count(tbm.id) from t_business_member_relation tbm where tbm.business_id = #{businessId,jdbcType=INTEGER} and tbm.member_id = #{memberId,jdbcType=INTEGER} and tbm.role_business_id is not null </select>
是經過參數名來引用的
注:假設Mapper.java文件裏引用的是Spring的java
org.springframework.data.repository.query.Param;
但是Mapper.xml中使用的是mybatis 的使用方法,那麼就會例如如下的錯誤spring
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'businessId' not found. Available parameters are [1, 0, param1, param2]