Adding multiple EntityListeners to an Entity in JPA 2
The ability to attach lifecycle events to an entity using simple annotations sometimes is a neat feature in the Java Persistence API. The following short snippets demonstrate how to bind and trigger the different available lifecycle events using an embedded derby database and a bunch of annotations. Dependencies I’m using Hibernate as persistence manager here and Derby as an easy to setup database. In the last step we’ll be writing a test that’s why we’ve added JUnit and Hamcrest. ...