-->
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: PostInsertEventListener
PostPosted: Fri Jun 29, 2007 7:21 am 
Newbie

Joined: Fri Jun 29, 2007 6:59 am
Posts: 4
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using: Mysql V5

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

I have implemented a org.hibernate.event.PostInsertEventListener and wired it up to the SessionFactory (via Spring).

The listener executes a task in a new thread.

The task queries via Hibernate, but the results do not contain the newly inserted data.

If I pause the task (Thread.sleep(...)) before the query then the newly inserted data is contained in the returned list.

I assume that this happens because the transaction has not yet completed and been committed, although i would expect the data to be committed before any Post Insert events are fired.....

Is there any way to configure the events to fire after the transaction has totally completed?

Any advice would be appreciated...

Grant


Top
 Profile  
 
 Post subject: Fixed this
PostPosted: Mon Jul 02, 2007 4:31 am 
Newbie

Joined: Fri Jun 29, 2007 6:59 am
Posts: 4
I managed to fix this.....

I stored all Event's in a map against their transactions ie... Map<Transaction , List<Event>>

When the Transaction completes then the afterTransactionCompletion(Transaction tx) method of Interceptor is called and I retreive the stored Events based on the Transaction and deal with them further.

Note the Event in this case is my own class and not a Hibernate class.


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.