I have created a listener to audit entity objects as they are saved and updated:
So far, everything I've done to inject the EntityManager has failed because entityManager remains null. Is there a way to do this? Thanks.Code:@EntityListeners(value = {MyEntityListener.class}) ... public class MyEntityListener { private EntityManager entityManager; @PersistenceContext public void setEntityManager(EntityManager em) { this.entityManager = em; } @PrePersist public void auditInsert(Object o) { // use this.entityManager here } @PreUpdate public void auditUpdate(Object o) { // use this.entityManager here } }


Reply With Quote
