@AuditJoinTable not working while auditing the many to many relations
I am using Spring Boot 1.3.2 and Spring Data JPA 1.9.4 with MS Sql server2014 database for process for process of mapping a many-to-many relationship.
I have two tables with entities Book & Publisher. where they have many to many relations ship with BookPublisher table and BookPublisher entity.
I used hibernate envers 4.3.3 final to audit the each entity. Book_AUD and Publisher_AUD and BookPublisher_AUD tables created automatially by placing the @Audited annotation on each entity.
Book_AUD and Publisher_AUD are working properly to audit the inserting, updating and deleting.
Record is getting saved to join table when save the record in Book table with set of publisher records. But auditing happen only in inserting BookPublisher_AUD table, not in updating the deleting.
I used @AuditJoinTable annotation to audit the relation mapping table as below.
@ManyToMany(fetch = FetchType.EAGER) @JoinTable(name = "BookPublisher", joinColumns = @JoinColumn(name = "BookId", referencedColumnName = "BookId"), inverseJoinColumns = @JoinColumn(name = "PublisherId ", referencedColumnName = "PublisherId")) @WhereJoinTable(clause = "isActive = 1 ") @AuditJoinTable private Set<Publisher> publishers; Is there any way to audit the relational mapping table in hibernate envers or any wrong in using @AuditJoinTable annotation?
I am very much new to the hibernate envers, so i just added the @Audited annotation to Book and publisher entity to audit but not to BookPublisher entity. I removed the AuditJoinTable annotation in collection mapping element in Book entity but no use. I added only three properties in my application properties file as below spring.jpa.hibernate.ddl-auto=update spring.jpa.properties.org.hibernate.envers.audit_table_suffix=Audit Still i auditing not working to capture the updating and deleting records. So can you please give sample example code to prove solution.
I did code changes , now auditing happen only in inserting & deleteing the collection publisher object from Book entity via Book repository. Is there any limitation in hibernate envers to not support directly interact the BookPublisher repository?
|