@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<String, Object>做为参数:
@SelectProvider(type = SqlProvider.class, method = "selectUser2")
@ResultMap("userMap")
public User getUser2(@Param("userId") long userId);
public String selectUser2(Map<String, Object> para) {
return "select * from user where userId=" + para.get("userId");
}