mybatis 各种注解备注

@SelectProvider
@UpdateProvider
@InsertProvider
@DeleteProvider
example:

public interface UserMapper {
    @SelectProvider(type = SqlProvider.class, method = "selectUser")
    @ResultMap("userMap")
     public User getUser(long userId);

     public class SqlProvider {
        public String selectUser(long userId) {
          return "select * from user where userId=" + userId;
        }
    }  
}

但是,如果在getUser方法中,对userId方法使用了@Param注解的话,那么相应selectUser方法必须接受Map做为参数:

@SelectProvider(type = SqlProvider.class, method = "selectUser2")
     @ResultMap("userMap")
     public User getUser2(@Param("userId") long userId);


 public String selectUser2(Map para) {
         return "select * from user where userId=" + para.get("userId");
  }

你可能感兴趣的:(mybatis 各种注解备注)