-->
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: Interceptor onFlush()
PostPosted: Mon Feb 09, 2009 5:21 pm 
Newbie

Joined: Mon Feb 09, 2009 5:00 pm
Posts: 2
Hibernate version: 3.2.6
Spring version: 2.5.3

I have a requirement where in, at the time of a write to the DB, I need to ensure certain "states" are met - I have to do this in code. If the states are NOT met, I would like to trigger a rollback. My unit of work is run within a transaction boundary.

I have been playing with Hibernate's session Interceptor that will allow me to intercept preFlush, onFlushDirty and beforeTransactionCompletion. Here is what I found in my analysis of these APIs. I see preFlush being called at various points in my code - not all of which write to my database. I didn't think beforeTransactionCompletion was the right API since the flush as already been called at this point and any code that I add at this point would only just prevent the "commit" part of my transaction. The onFlushDirty(), on the other hand, seems to get called when there is a "dirty" entity encountered during a flush() - however, even that can be called at various point, but not all result in a DB write.

From what I can see, onFlushDirty is the closest to what I want, but I have no guarantees that every time the API is hit, there is a write to the DB. I would like to confine my check to only the cases where I believe there will, infact, be a DB write. Is there some other mechanism I should be looking at?

I would love to hear from folks that have used the Hibernate Interceptor to confirm if I am on the right path here.

Madhuri


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.