Solutions for mybatis to pass multiple parameters (three)
The editor will share three solutions to the problem of mybatis passing multiple parameters. The details are as follows:
The first scheme
Function method of Dao layer
Corresponding mapper xml
Where, #{0} represents the first parameter received in Dao layer, #{1} represents the second parameter in Dao layer, and more parameters can be added later.
The second scheme
This method uses map to transfer multiple parameters
Function method of Dao layer
Corresponding mapper xml
Service layer call
Personally, I think this method is not intuitive enough. When I see the interface method, I can't directly know what the parameters to be transmitted are.
The third scheme
Function method of Dao layer
Corresponding mapper xml
Personally, I think this method is better. It allows developers to see the Dao layer method and know what parameters to pass. I personally recommend this scheme.
The above is the solution of mybatis passing multiple parameters introduced by Xiaobian. I hope it will be helpful to you!