-->
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: onFlushDirty of hibernate interceptor called Multiple times
PostPosted: Wed May 24, 2017 12:52 am 
Newbie

Joined: Tue May 23, 2017 7:39 am
Posts: 1
Hibernate version
4.

JPA version
1.1

Name and version of the database you are using:
SQL server 5

My application supposed to log the modification information on any property of an entity or creation of any new record or deletion of record
Updated entity(Id of updated entity and updated by etc....) should go into master table and corresponding updated property(old value and new value reference of master table etc...) should inserted into child table . All this updated property recorded is done in onFlushDirty method.

But what surprising me is that the onFlushDirty method is called too many times in a transaction which is managed by "javax.ejb.TransactionAttribute" . Hence multiple duplicate records get inserted for a single update of record, the onFlushDrity method may be called once when the method is end(but the transaction is not!).

By hibernated listener the call back method of @PostUpdate is called once on end of transaction, but it may not full fill my requirement because it is taking a single input parameter which is not strait forward to track old and new value of updated property .

Please give me the solution .


Top
 Profile  
 
 Post subject: Re: onFlushDirty of hibernate interceptor called Multiple times
PostPosted: Wed May 24, 2017 1:16 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Just use Hibernate Envers instead of implementing your own Audit Loggin framework.


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.