-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: @AuditJoinTable not working while auditing the many to many
PostPosted: Sun Oct 16, 2016 2:25 pm 
Newbie

Joined: Sun Oct 16, 2016 1:22 pm
Posts: 2
@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_suffi‌​x=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?


Top
 Profile  
 
 Post subject: Re: @AuditJoinTable not working while auditing the many to many
PostPosted: Mon Oct 17, 2016 11:01 am 
Hibernate Team
Hibernate Team

Joined: Wed Jun 15, 2016 9:04 am
Posts: 24
Could you explain to me your BookPublisher entity?

From what you've shown, you have two entities called Book and Publisher which has a ManyToMany relationship, but that relationship is managed by Hibernate through a join table. It would certainly be helpful if you could clarify this. I would rather not get into a lengthy answer based on a series of assumptions, so some additional context here would be helpful.

1. What is the precise mappings between Book, Publisher, and BookPublisher (if applicable).
2. Can you show some code on what you've tried where updating/deleting does not work.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.