- Spring in @param
/** * Query the specified user and Enterprise association there is no configuration role @param businessid memberid @return */ int
- The Param in MyBatis
/** * Query the specified user and Enterprise association there is no configuration role @param businessid memberid @return */ int
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 = #{0,jdbctype=integer} = #{1,jdbctype=integer} 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 = #{businessid,jdbctype=INTEGER} = #{memberid,jdbctype= INTEGER} 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
Org.mybatis.spring.MyBatisSystemException:nested exception is org.apache.ibatis.binding.BindingException: Parameter ' Businessid ' not found. Available parameters is [1, 0, param1, param2]
As follows
So be sure to pay attention to the consistency of @param reference and use when using
The best way to do this is to use a note of which package is referenced.
Like when you're quoting MyBatis.
import Org.apache.ibatis.annotations.Param;
This article is reproduced from http://blog.csdn.net/gao36951/article/details/44258217
Differences in @param usage in @param and MyBatis in spring