Skip to main content

Delete

Hint

This article is generated by AI translation.

Delete data with LambdaTemplate as follows:

Tip

For building conditions used in deletes, see where builder.

LambdaTemplate lambda = ...;
int result = lambda.delete(User.class)
.eq(User::getId, 1) // match condition
.doDelete();
// result is affected row count

Empty conditions

Deleting without any condition is dangerous and is blocked by default. To delete an entire table intentionally, call allowEmptyWhere for that operation.

LambdaTemplate lambda = ...;
int result = lambda.deleteByEntity(User.class)
.allowEmptyWhere() // allow doDelete with no conditions
.doDelete();
// result is affected row count