-->
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.  [ 2 posts ] 
Author Message
 Post subject: reentrant event listeners within a transaction
PostPosted: Thu Jun 28, 2007 4:01 am 
Newbie

Joined: Tue Jan 24, 2006 10:42 pm
Posts: 3
Hi,
I am using Hibernate 3.2.2 ga.

I've been struggling to get some work done in an event listener (specifically the pre-update event listener, but I think the problem is more general). I want to be able to make some db changes (i.e. update a few existing entities and add some new ones) within the event listener. Everything I've tried seems to end up in different types of exceptions getting thrown , for e.g.:

Code:
org.hibernate.AssertionFailure: collection [XXXXX] was not processed by flush()
at org.hibernate.engine.CollectionEntry.postFlush(CollectionEntry.java:205)
   at org.hibernate.event.def.AbstractFlushingEventListener.postFlush(AbstractFlushingEventListener.java:333)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:28)
....


I'd be happy to be proved wrong, but I'm getting the increasingly frustrating feeling that the event listeners do not support re-entrant session method calls (i.e., flush/persist/update etc) and that in order to get a listener to update the database you need a separate new session for it.

This is a shame as I would like my listener to be able to make the changes within the same JTA transaction that was used for the normal operations that took place before the listener got fired so that the listener's work gets committed/rolledback synchronously with the rest of the operations.

Nothing in the documentation seems to indicate that listeners can't reuse the existing session.

If this is not possible, is there any other way I can accomplish what I want to do?

Thanks,
Ishaaq
Code:


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 31, 2007 4:12 am 
Beginner
Beginner

Joined: Mon Sep 12, 2005 3:27 am
Posts: 48
Hello,

same problem here. Problem unknown, but seems only to occur if touching a collection of a m:n relationship inside a event-listener.

Jira-Issue opened http://opensource.atlassian.com/projects/hibernate/browse/HHH-2751, but no work on it at time :-/

You can vote for it....


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