Annotation Interface Select


@Target(METHOD) @Retention(RUNTIME) public @interface Select
Indicates a select operation.

The annotated method must be a member of a Dao annotated interface.

 @Entity
 public class Employee {
     ...
 }

 @Dao
 public interface EmployeeDao {

     @Select
     String selectNameById(Integer id);

     @Select
     List<Employee> selectNamesByAgeAndSalary(Integer age, BigDecimal salary);

     @Select
     Employee selectById(Integer id);

     @Select
     List<Employee> selectByExample(Employee example);

     @Select(strategy = SelectStrategyType.STREAM)
     <R> R selectSalary(Integer departmentId, Function<Stream<BigDecimal>, R> mapper);
 }
 
The method may throw following exceptions:
See Also:
  • Element Details

    • queryTimeout

      int queryTimeout
      The query timeout in seconds.

      If not specified, Config.getQueryTimeout() is used.

      Returns:
      the query timeout
      See Also:
      Default:
      -1
    • fetchSize

      int fetchSize
      The fetch size.

      If not specified, Config.getFetchSize() is used.

      Returns:
      the fetch size
      See Also:
      Default:
      -1
    • maxRows

      int maxRows
      The maximum number of rows.

      If not specified, Config.getMaxRows() is used.

      Returns:
      the maximum number of rows
      See Also:
      Default:
      -1
    • strategy

      SelectType strategy
      Returns:
      the strategy for handling objects mapped to a result set.
      Default:
      RETURN
    • fetch

      FetchType fetch
      Returns:
      the fetch type.
      Default:
      LAZY
    • ensureResult

      boolean ensureResult
      Whether to ensure that one or more rows are found in a result set.

      if true and no row is found, NoResultException is thrown from the method.

      Returns:
      whether to ensure that one or more rows are found in a result set
      Default:
      false
    • ensureResultMapping

      boolean ensureResultMapping
      Whether to ensure that all entity properties are mapped to columns of a result set.

      This value is used only if the result set is fetched as an entity or a entity list.

      If true and there are some unmapped properties、 ResultMappingException is thrown from the method.

      Returns:
      whether to ensure that all entity properties are mapped to columns of a result set
      Default:
      false
    • mapKeyNaming

      MapKeyNamingType mapKeyNaming
      The naming convention for keys of Map<Object, String>.

      This value is used only if a result set is fetched as Map<Object, String> or List<Map<Object, String>>.

      Returns:
      the naming convention
      Default:
      NONE
    • sqlLog

      SqlLogType sqlLog
      Returns:
      the output format of SQL logs.
      Default:
      FORMATTED
    • aggregateStrategy

      Class<?> aggregateStrategy
      Defines how an aggregate is constructed.

      Specifies the interface annotated with AggregateStrategy.

      Returns:
      the class representing the aggregation strategy, or Void.class if not specified
      Default:
      java.lang.Void.class