spring-projects / spring-projects/spring-data-mongodb

BeforeDeleteEvent<DocumentType> when calling 'deleteAll()' on repository. [DATAMONGO-2471]

Open
#3,326 0 comments 0 reactions 1 assignee View on GitHub

@christophstrobl is already working on this.

Since Dec 30, 2020.

type: enhancement
Dominant language
Java
Stars
1.7k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

hoemich opened DATAMONGO-2471 and commented

Given a Repository<DocumentType, KeyType> repository, when I call

repository.delteAll()

an BeforeDeleteEvent is beeing published. However I won't get it in my AbstractMongoEventListener.

On the other hand, an EventListener like

@EventListner
public void onEvent(BeforeDeleteEvent event)
{}

gets it. In the debugger it then looks like this:

event = BeforeDelteEvent@xxx
    type = null
    document = {Document@yyy} size = 0
    collectionName = "theCollection"
    timestamp = 12345678990
    source = {Document@yyy} size = 0

So currently I can use the collection name to match it to the right Repository and deduct that this is a deleteAll event.

It would be nice if I could handle this event somehow in the AbstractMongoEventListener either in the onBeforeDelete or in some other overridable method. If that is technically possible


Affects: 2.2.4 (Moore SR4)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.