MyBatis Four solutions for multi-parameter transfer

Source: Internet
Author: User

MyBatis Four solutions for multi-parameter transfer

Code exception: Org.apache.ibatis.binding.BindingException:Parameter ' param ' not found.

For a long time no durable layer mybatis frame, there are some anomalies today. Check out the original is a multi-parameter problem, this problem has occurred before, now put the solution down to facilitate other people and their own later abnormal resolution.

First declare, " I am using the DAO Interface way "

programme I

The DAO parameter is passed to the Vo,xml configuration: parametertype= "*. VO "

Scenario Two

The DAO parameter is passed to map,XML configuration: parametertype= "HashMap". Of course the service layer needs to put parameters into the map.

This method I used to use before, but not too intuitive, interface method can not directly clear what the parameters are

Programme III

The DAO parameter is still written as it is written, but ParameterType is not written in the XML configuration

Parameters are occupied by #{0}, #{1}, #{*}

Scenario Four

DAO layer is not written in @param,xml configuration using annotations parametertype

e.g

    Integer getCountByNameAndPass(@Param("userName") String userName,@Param("password")String password);

The individual feels that, in comparison, the scheme four best

PS: Scenario one or two No attempt was made to write parametertype in the configuration. Readers can try it on their own.

MyBatis Four solutions for multi-parameter transfer

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.