Describe the bug
BeforeDeleteEvent is not fired if deletion was performed inside of performTransaction method.
Sample
Having the following code to delete entity by Key:
@RequiredArgsConstructor
@Service
public class MyEntityClass {
private final DatastoreTemplate datastoreTemplate;
public void deleteRole(Key key) {
datastoreTemplate.performTransaction(transactionalRepo -> {
transactionalRepo.deleteById(key, MyEntity.class);
return null;
});
}
}
Please note that deletion is performed inside of performTransaction method and the code below has been never called:
@Slf4j
@Component
public class DeleteEventHandler {
@EventListener
public void handleBeforeDeleteEvent(BeforeDeleteEvent event) {
if (event == null) {
log.debug("Received BeforeDeleteEvent null");
return;
}
for (Key key : event.getKeys()) {
// do some stuff
log.info("The entity with key: {} is going to be deteted", key);
}
}
}
Note:
This issue is reproducible for all kind events. Tested on thse:
Describe the bug BeforeDeleteEvent is not fired if deletion was performed inside of performTransaction method.
Sample Having the following code to delete entity by Key:
Please note that deletion is performed inside of
performTransaction
method and the code below has been never called:Note: