The instance code of the mybatis pass in parameter
The parametertype attribute is mentioned in the select, insert, update and delete elements of mybatis. The parametertypes that mybatis can now use include basic data types and Java complex data types
Basic data type: including int, string, date, etc. Only one basic data type can be passed in as a parameter. The passed in value can be obtained by #{parameter name}
Complex data types: including Java entity classes and maps. The passed in value can be obtained by #{attribute name} or #{keyname} of map
Examples of basic data type parameters:
Query teacher list according to class ID
XML file
java code
Example of Java entity type parameters:
java code
Example map parameters:
java code
In addition, mybatis also provides a way to use annotations to enter multiple parameters. In this way, you need to add @ param annotation on the parameters of the interface
Example:
Interface method
XML file
Test code
Now let's share mybatis biography @ H_ 502_ 81@
1. When the parameter passed is list:
1.1 mapper interface:
1.2 mapper. In the XML file:
The above is the example code of mybatis incoming parameters introduced by Xiaobian. I hope it will be helpful to you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!