@FunctionalInterface public interface SelectDSLCompleter extends Function<QueryExpressionDSL<SelectModel>,Buildable<SelectModel>>
This function is intended to by used in conjunction with utility methods like the select methods in
MyBatis3Utils.
For example, you can create mapper interface methods like this:
@SelectProvider(type=SqlProviderAdapter.class, method="select")
List<PersonRecord> selectMany(SelectStatementProvider selectStatement);
BasicColumn[] selectList =
BasicColumn.columnList(id, firstName, lastName, birthDate, employed, occupation, addressId);
default List<PersonRecord> select(SelectDSLCompleter completer) {
return MyBatis3Utils.select(this::selectMany, selectList, person, completer);
}
And then call the simplified default method like this:
List<PersonRecord> rows = mapper.select(c ->
c.where(occupation, isNull()));
You can implement a "select all" with the following code:
List<PersonRecord> rows = mapper.select(c -> c);
Or
List<PersonRecord> rows = mapper.select(SelectDSLCompleter.allRows());
There is also a utility method to support selecting all rows in a specified order:
List<PersonRecord> rows = mapper.select(SelectDSLCompleter.allRowsOrderedBy(lastName, firstName));
| Modifier and Type | Method and Description |
|---|---|
static SelectDSLCompleter |
allRows()
Returns a completer that can be used to select every row in a table.
|
static SelectDSLCompleter |
allRowsOrderedBy(SortSpecification... columns)
Returns a completer that can be used to select every row in a table with specified order.
|
static SelectDSLCompleter allRows()
static SelectDSLCompleter allRowsOrderedBy(SortSpecification... columns)
columns - list of sort specifications for an order by clauseCopyright © 2016–2019 MyBatis.org. All rights reserved.