-->
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.  [ 4 posts ] 
Author Message
 Post subject: recursion using Interceptor.onFlushDirty()
PostPosted: Mon Sep 22, 2003 10:49 am 
Regular
Regular

Joined: Mon Sep 08, 2003 4:53 am
Posts: 70
Location: Germany
I tried to use an Interceptor to create protocol objects for changes made on persistent objects. Each protocol object maps the change of the state of a single property of the persistent object. Creating the protocol objects works very well with the Interceptor.

Now I want to store the protocol objects to the database with session.save(protocol object) in onFlushDirty(). This causes a flush() and I get a recursion.

What's the best thing to do here? Implement findDirty() on my own (I tried to do this, but got some weird side effects during save), or save the protocol objects in postFlush()? Or anything else?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 22, 2003 12:15 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
I do something very similiar, creating a DeltaSet object in the onflushDirty() encompassing a set of PropertyChange attributes.

The way I do this is to push the DeltaSet through an auditing framework to a JMS queue. A queue listener then persists the DeltaSet to the database. I have setups where it uses a seperate SessionFactory and a setup where it uses straight JDBC.

HTH


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 22, 2003 12:34 pm 
Regular
Regular

Joined: Mon Sep 08, 2003 4:53 am
Posts: 70
Location: Germany
It seems, that you are using different sessions/transactions to save the DeltaSet and to save the persistent object.

I need to save the persistent object and the protocol object in the same transaction. Any idea?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 22, 2003 5:25 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
The feed to the JMS queue happens on the same XA transaction in my setup. So if the DB operations rollback, the DeltaSet stuff is not released to the queue...

Is your interceptor Session-level or SessionFactory-level? Assuming JTA: if session, then grab another session from the factory without the interceptor; else define another session factory without the interceptor, but which uses the same JTA datasource.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.