我们在使用mybatis时,可以有三种方式
1.在mapper.xml中定义sql语句,关联dao中的接口方法
2.使用@Select,@Update,@Insert,@Delete在注解里面写上sql
3.使用@SelectProvider,@UpdateProvider,@InsertProvider,@DeleteProvider通过调用java方法返回sql语句。
下面看下源码中的注释SelectProvider
/**
* The annotation that specify a method that provide an SQL for retrieving record(s).
*
* <p>
* <b>How to use:</b>
*
* <pre>
* public interface UserMapper {
*
* @SelectProvider(type = SqlProvider.class, method = "selectById")
* User selectById(int id);
*
* public static class SqlProvider {
* public static String selectById() {
* return "SELECT id, name FROM users WHERE id = #{id}";
* }
* }
*
* }
* </pre>
*
* @author Clinton Begin
*/
UpdateProvider
/**
* The annotation that speci