@FunctionalInterface public interface CountDSLCompleter extends Function<CountDSL<SelectModel>,Buildable<SelectModel>>
This function is intended to by used in conjunction with a utility method like
MyBatis3Utils.countFrom(ToLongFunction, CountDSL, CountDSLCompleter)
For example, you can create mapper interface methods like this:
@SelectProvider(type=SqlProviderAdapter.class, method="select")
long count(SelectStatementProvider selectStatement);
default long count(CountDSLCompleter completer) {
return MyBatis3Utils.count(this::count, person, completer);
}
And then call the simplified default method like this:
long rows = mapper.count(c ->
c.where(occupation, isNull()));
You can implement a "count all" with the following code:
long rows = mapper.count(c -> c);
Or
long rows = mapper.count(CountDSLCompleter.allRows());
| Modifier and Type | Method and Description |
|---|---|
static CountDSLCompleter |
allRows()
Returns a completer that can be used to count every row in a table.
|
static CountDSLCompleter allRows()
Copyright © 2016–2019 MyBatis.org. All rights reserved.