| 
					
						 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 
					
  
						
					 |