Notification when an entity inserted, updated or deleted

Hi All,

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?

Any suggestion?

You could extend EntityLog and do it that way. Look into the EntityLog class to find which method(s) you’d have to override.

1 Like

Hi @czegledi.balazs,

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.

Hope it helps.