-->
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.  [ 1 post ] 
Author Message
 Post subject: hibernate interceptor auditing log design issue.
PostPosted: Sun Mar 30, 2014 5:20 am 
Newbie

Joined: Sun Mar 30, 2014 5:17 am
Posts: 3
What i do

I have a async system which react whenever a new entity is created in main system and this async system query the database for the newly created entities.

How i do it

For creating the msgs for async system i use hibernate interceptor.

So whenever a new entity is created the onSave method of the interceptor is called and i

save the entity id in a list, and now when afterTransactionComplete(Transaction tx) is

called , i flush all the entity id in the list to async system using a messaging system(ActiveMq).

What is the problem

Now the problem arises when there are more then one transaction are in process.. and both

transactions creates entities.

Let me take a example:

Tx_A create entity EA1, EA2.

Tx_B creates entity EB1, EB2.

Now let say execution flow happens this way:

[1] onSave for EA1, i add EA1 id to flushList

[2] onSave for EB1, i add EB1 id to flushList

[3] afterTransactionComplete(tx) for Tx_A

Now at this point i will flush EA1 and EB1 id to async system which when query database

for EB1 found null as transaction Tx_B is still not completed.

Now this issue can be solve if in onsave call i can get the transaction id and then in afterTransactionCompletion i can flush only entity related to that transaction

[1] Now Is there a way to get this transaction id ?

[2] Is there some other solution for the above problem ?

i am using hibernate 4.2.2


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

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.