- Spring in @param
/** * 查询指定用户和企业关联有没有配置角色 * @param businessId memberId * @return */ int selectRoleCount(@Param("businessId") Integer businessId,@Param("memberId"
- The Param in MyBatis
/** * 查询指定用户和企业关联有没有配置角色 * @param businessId memberId * @return */ int selectRoleCount(@Param("businessId") Integer businessId,@Param("memberId"
On the surface, there is no difference between the two, but it is different when used in XML files, and the @param in spring need to refer to variables as follows in XML.
<select id="selectRoleCount" resultType="java.lang.Integer" >select count(tbm.id) from t_business_member_relation tbm where#{0,jdbcType=INTEGER} and#{1,jdbcType=INTEGER} andisnot null</select>
Values are taken according to the order of the parameters, and starting from 0. The MyBatis @param in XML is the following reference to the variable
<select id="selectRoleCount" resultType="java.lang.Integer" > select count(tbm.id) from t_business_member_relation tbm where#{businessId,jdbcType=INTEGER} and#{memberId,jdbcType=INTEGER} andisnot null </select>
is referenced by a parameter name.
Note: If the Mapper.java file is referenced by the spring
org.springframework.data.repository.query.Param;
However, the use of MyBatis is used in Mapper.xml, then the following error
nestedis‘businessId‘not found. Available parameters are [10, param1, param2]
As follows
So be sure to pay attention to the consistency of @param reference and use when using
Differences in @param usage in @param and MyBatis in spring