Hello,
I have a implementation code for hibernate's PreInsertEventListener, where I need to do a hql query to check some data - based on that query, I need to update the object which originally caused this PreInsertEventListener. Problem is that when query() is called in this code which implements PreInsertEventListener, hibernate tries to flush the session, which in turn tries to do the Insert again, which in turn triggers this code for PreInsertEventListener, which is calling my query() again - it just recurses and ends after somepoint giving BatchUpdateException().
Question is how do I prevent this recursive behavior? How can I do a query within this code so that it won't flush to trigger another Insert event? Is there a way to do this query in a different session?
Thanks.
|