I would like to notify a user (by email), when an entity is successfully inserted, created or deleted in the DB. Using EntityListener would be obvious, but not, due to its “before…” methods, not to mention they should be configured to each entity, right?
Using EntityLog would be great. Is there a way to use this?
You could use EntityListener, but you’d have to implement a few things to make it work.
First, implement the listener for a superclass or interface (StandardEntity, for example). If using a superclass, it would be easier (@Listener in the superclass). Otherwise (interface), you’d have to programatically register the listener for each class implementing the interface on application startup. See Registration of entity listeners in the docs.
From your description, it seems that using a transaction listener would be better. I wouldn’t use EntityLog because you would increase the complexity of the code (your code would trigger when the entity log triggers) and entity log would be mandatory for each entity that you need to notify by e-mail.