MyBatis calling the MySQL stored procedure

Source: Internet
Author: User

To establish a stored procedure:
DELIMITER $ $USE ' test ' $ $DROP PROCEDURE IF EXISTS ' user_user_selectuserbyproandcity_sp ' $ $CREATE definer= ' demao ' @ '% ' PROCEDURE ' user_user_selectuserbyproandcity_sp ' (in Provinceid int,in cityid int,in pageIndex int,in pageSize INT) begin< C0/>declare proid INT DEFAULT 0;    DECLARE ciid INT DEFAULT 0;        SELECT *, (select  COUNT (*) from user_user_t whereprovince_id like CONCAT ('% ', Provinceid, '% ') and  city_id like CONCAT ('% ', Cityid, '% ')) as Usercountfrom user_user_twhere province_id like CONCAT ('% ', Provinceid, '% ') and city_id like CONCAT ('% ', Cityid, '% ') LIMIT pageindex,pagesize;    end$$

Mapper Inside Call:
<select id= "selectuserbyprovinceandcity" resultmap= "Baseresultmap" statementtype= "CALLABLE" >{CALL user_user_ SELECTUSERBYPROANDCITY_SP (#{provinceid,mode=in,jdbctype=integer},#{cityid,mode=in,jdbctype=integer},#{ Pageindex,mode=in,jdbctype=integer},#{pagesize,mode=in,jdbctype=integer})}</select>

in, incoming parameters, out, outgoing parameters.

MyBatis calling the MySQL stored procedure

Related Article

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.