@Target(value=METHOD)
@Retention(value=RUNTIME)
public @interface Select
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:
DomaNullPointerException if any of the method parameters are null
SqlFileNotFoundException if sqlFile is true and a SQL file is not
found
UnknownColumnException if a property whose mapped column is included in a result
set is not found
NonUniqueResultException if an unique row is expected but two or more rows are
found in a result set
NonSingleColumnException if a single column is expected but two or more columns are
found in a result set
NoResultException if ensureResult() is true and no row is found in a
result set
ResultMappingException if ensureResultMapping() is true and all
entity properties are not mapped to columns of a result set
JdbcException if a JDBC related error occurs
SelectOptions| Modifier and Type | Optional Element and Description |
|---|---|
boolean |
ensureResult
Whether to ensure that one or more rows are found in a result set.
|
boolean |
ensureResultMapping
Whether to ensure that all entity properties are mapped to columns of a result set.
|
FetchType |
fetch |
int |
fetchSize
The fetch size.
|
MapKeyNamingType |
mapKeyNaming
The naming convention for keys of
Map<Object, String>. |
int |
maxRows
The maximum number of rows.
|
int |
queryTimeout
The query timeout in seconds.
|
SqlLogType |
sqlLog |
SelectType |
strategy |
public abstract int queryTimeout
If not specified, Config.getQueryTimeout() is used.
Statement.setQueryTimeout(int)public abstract int fetchSize
If not specified, Config.getFetchSize() is used.
Statement.setFetchSize(int)public abstract int maxRows
If not specified, Config.getMaxRows() is used.
Statement.setMaxRows(int)public abstract SelectType strategy
public abstract FetchType fetch
public abstract boolean ensureResult
if true and no row is found, NoResultException is thrown from the method.
public abstract boolean ensureResultMapping
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.
public abstract MapKeyNamingType mapKeyNaming
Map<Object, String>.
This value is used only if a result set is fetched as Map<Object, String> or List<Map<Object, String>>.
public abstract SqlLogType sqlLog