Package org.mybatis.dynamic.sql.delete
Interface DeleteDSLCompleter
- All Superinterfaces:
Function<DeleteDSL<DeleteModel>,
Buildable<DeleteModel>>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface
public interface DeleteDSLCompleter
extends Function<DeleteDSL<DeleteModel>,Buildable<DeleteModel>>
Represents a function that can be used to create a simplified delete method. When using this function
you can create a method that does not require a user to call the build() and render() methods - making
client code look a bit cleaner.
This function is intended to be used in conjunction with a utility method like
MyBatis3Utils.deleteFrom(ToIntFunction, SqlTable, DeleteDSLCompleter)
For example, you can create mapper interface methods like this:
@DeleteProvider(type=SqlProviderAdapter.class, method="delete") int delete(DeleteStatementProvider deleteStatement); default int delete(DeleteDSLCompleter completer) { return MyBatis3Utils.deleteFrom(this::delete, person, completer); }
And then call the simplified default method like this:
int rows = mapper.delete(c -> c.where(occupation, isNull()));
You can implement a "delete all" with the following code:
int rows = mapper.delete(c -> c);
Or
long rows = mapper.delete(DeleteDSLCompleter.allRows());
- Author:
- Jeff Butler
-
Method Summary
Modifier and TypeMethodDescriptionstatic DeleteDSLCompleter
allRows()
Returns a completer that can be used to delete every row in a table.
-
Method Details
-
allRows
Returns a completer that can be used to delete every row in a table.- Returns:
- the completer that will delete every row in a table
-