Envers is not auditing on a entity update
gonzaloferreyra Nov 29, 2010 11:02 AMHello, we were using Hibernate 3.3 with Envers 1.1 successfully in a project until now, but we decided to migrate to Hibernate + Envers 3.5.1 and we are facing some troubles with it.
For example, envers is not auditing any modifications when the DAO EJB merges the entity, but it works well with persist and remove.
Here is the configuration in persistence.xml:
<property name="hibernate.ejb.event.post-insert" value="org.hibernate.ejb.event.EJB3PostInsertEventListener,org.hibernate.envers.event.AuditEventListener"/> <property name="hibernate.ejb.event.post-update" value="org.hibernate.ejb.event.EJB3PostUpdateEventListener,org.hibernate.envers.event.AuditEventListener"/> <property name="hibernate.ejb.event.post-delete" value="org.hibernate.ejb.event.EJB3PostDeleteEventListener,org.hibernate.envers.event.AuditEventListener"/> <property name="hibernate.ejb.event.pre-collection-update" value="org.hibernate.envers.event.AuditEventListener" /> <property name="hibernate.ejb.event.pre-collection-remove" value="org.hibernate.envers.event.AuditEventListener" /> <property name="hibernate.ejb.event.post-collection-recreate" value="org.hibernate.envers.event.AuditEventListener" />
And this is one of the entities which is suffering this problem:
@Entity @Table(name = "termino_tesauro", uniqueConstraints={@UniqueConstraint(columnNames="termino")}) @Audited @AuditTable(schema="auditoria", value="termino_tesauro_auditoria") public class TerminoTesauro implements Serializable { public static final String CRITERIO_BUSQUEDA_TERMINO = "termino"; @Id @Column(name = "id", nullable = false) @GeneratedValue(generator="palabra_tesaurus_seq") @SequenceGenerator(name="palabra_tesaurus_seq", sequenceName="palabra_tesaurus_id_seq") private Long id; @Column(name="termino") private String termino; @Column(name="definicion") private String definicion; //getters, setters, constructors and others methods.. }
We've read the documentation files, but we are out of ideas about what is wrong. Looking at the generated sql, hibernate it's not trying to insert any audit inserts when merges the entity, but it merges well the entity (generating the correct insert in the 'auditoria' schema).
Thanks in advance
Gonzalo Ferreyra