Differences in @param usage in @param and MyBatis in spring

Source: Internet
Author: User

    1. Spring in @param
    /**       * Query the specified user and Enterprise association there is      no configuration role @param  businessid  memberid      @return      */     int
    1. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.