'how to make RepositoryEventHandler working in spring boot
@Component
@RepositoryEventHandler({Person.class})
public class RepositoryListener {
@HandleBeforeDelete
public void handleEventBeforeDelete(Person person){
java.lang.System.out.println("handleAuthorBeforeCreate");
}
@HandleAfterDelete
public void handleEventAfterDelete(Person person){
java.lang.System.out.println("handleAuthorAfterCreate");
}
@HandleBeforeSave
public void handleEventBeforeSave(Event event){
java.lang.System.out.println("handleAuthorBeforeSave");
}
@HandleAfterSave
public void handleEventAfterSave(Perrson person){
java.lang.System.out.println("yulin-11 handleAuthorAfterSave");
}
@HandleBeforeCreate
public void handEventBeforeCreate(Person person){
java.lang.System.out.println("handEventBeforeCreate");
}
@HandleAfterCreate
public void handleEventAfterCreate(Person person){
java.lang.System.out.println("handleEventAfterCreate");
}
}
I create the RepositoryListener as above. When I fire delete and post rest call in the controller, it doesn't invoke any of those methods in the RepositoryListener. (Person is my domain class). Does anyone know what I am missing? thx!
Solution 1:[1]
Check that comment below most probably it the answer, I didn't try it myself
It is called on the HTTP Requests done to the Data-REST exposed repositories, but not when you use any repository-method programmatically
link mentioned here
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mostafa Hassan |
