Annotation Interface Select


The annotation that specify an SQL for retrieving record(s).

How to use:

  • Simple:
    
     public interface UserMapper {
       @Select("SELECT id, name FROM users WHERE id = #{id}")
       User selectById(int id);
     }
     
  • Dynamic SQL:
    
     public interface UserMapper {
       @Select({ "<script>", "select * from users", "where name = #{name}",
           "<if test=\"age != null\"> age = #{age} </if>", "</script>" })
       User select(@NotNull String name, @Nullable Intger age);
     }
     
Author:
Clinton Begin
See Also: