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