The Entity Listener allows you to respond to the various changes to an entity that are made, e.g. when saving an entity to log this saving action. You can use the Entity Listener wizard to generate the required entity listener so that you only have to enter the code that has to be executed after triggering the event. A total of seven events are supported:

  1. In the entity editor, click Add Listener.
  2. Define a name for the entity listener under Name or apply the proposed name, e.g. CarListener.
  3. Under Callback methods, define which changes in the entity you want to generate the corresponding callback methods for, e.g. PrePersist.
  4. Click on Finish
  5. Under Project Management Entities, select the generated CarListener.java class and add the corresponding action code under Callback method.
Result:
Note:

Hibernate Documentation