Jul 9th, 2007, 02:32 PM
Child objects and hibernate interceptors
I've got a bit of an unusual test case. I need to send MyEntity to a JMS queue when any change occurs to any MyEntity or when any child object of MyEntity changes.
There are no further DB changes that need to be made once these changes are detected. However, I think I may need to do a find on a.id, b.id, or c.id for any MyEntity when those changes are detected.
/ | \
a b c
So I implemented MyEntity with an JMSAware interface (real name not important yet) . And I can gather those objects in onSave() and onDirtyFlush() and send those in onFlush() . My problem is these child object changes. My questions are:
1) Anyone done anything like this?
2) If I detect changes to Object a,b,c how do I know its under its own save or flush, and not the save or flush of MyEntity ?
3) If I do a "from MyEntity where a,b,c" (with the right joins of course) from the temp session created from the connection I get from onFlush() , is that legal ? I know the session is fragile in interceptors. Just a find won't create another cycle of save or dirtyFlush I don't think, But what about another transaction?
Last edited by iksrazal; Jul 9th, 2007 at 02:38 PM.
Reason: extra sentance trailing