@Test public void should_set_creation_date() throws Exception { AuditedEntity entity = new AuditedEntity(); getEntityManager().persist(entity); getEntityManager().flush(); assertNotNull(entity.getCreated()); assertNotNull(entity.getModified()); assertEquals(entity.getCreated().getTime(), entity.getModified()); }
@PrePersist public void persist(Object entity) { BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager(); Set<Bean<?>> beans = beanManager.getBeans(PrePersistAuditListener.class); for (Bean<?> bean : beans) { PrePersistAuditListener result = (PrePersistAuditListener) beanManager.getReference( bean, PrePersistAuditListener.class, beanManager.createCreationalContext(bean)); result.prePersist(entity); } }
AuditEntityListener { @PrePersist public void persist(Object entity) { BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager(); Set<Bean<?>> beans = beanManager.getBeans(PrePersistAuditListener.class); for (Bean<?> bean : beans) { PrePersistAuditListener result = (PrePersistAuditListener) beanManager.getReference( bean, PrePersistAuditListener.class, beanManager.createCreationalContext(bean)); result.prePersist(entity); } } }
AuditEntityListener { @PrePersist public void persist(Object entity) { BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager(); Set<Bean<?>> beans = beanManager.getBeans(PrePersistAuditListener.class); for (Bean<?> bean : beans) { PrePersistAuditListener result = (PrePersistAuditListener) beanManager.getReference( bean, PrePersistAuditListener.class, beanManager.createCreationalContext(bean)); result.prePersist(entity); } }  }
AuditEntityListener { @PrePersist public void persist(Object entity) { BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager(); Set<Bean<?>> beans = beanManager.getBeans(PrePersistAuditListener.class); for (Bean<?> bean : beans) { PrePersistAuditListener result = (PrePersistAuditListener) beanManager.getReference( bean, PrePersistAuditListener.class, beanManager.createCreationalContext(bean)); result.prePersist(entity); } }  @PrePersist void persist(Object entity); @PreUpdate void update(Object entity); }
AuditEntityListener { @PrePersist public void persist(Object entity) { BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager(); Set<Bean<?>> beans = beanManager.getBeans(PrePersistAuditListener.class); for (Bean<?> bean : beans) { PrePersistAuditListener result = (PrePersistAuditListener) beanManager.getReference( bean, PrePersistAuditListener.class, beanManager.createCreationalContext(bean)); result.prePersist(entity); } }  @PrePersist void persist(Object entity); @PreUpdate void update(Object entity);  }