-->
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.  [ 1 post ] 
Author Message
 Post subject: Problem with FlushEntityEventListener
PostPosted: Thu May 15, 2008 12:56 am 
Newbie

Joined: Fri Jul 07, 2006 6:20 am
Posts: 4
Hi,

I am working onn Audit functionality, using Java 1.5, Spring Core 2.5.2, Hibernate 3.2.5 and DB2.

I have implemented FlushEntityEventListener to populate Audit entity and persist it with the listener.

My code looks something like this -

public class FlushEntityEventListener extends DefaultFlushEntityEventListener
{
// ------------------------------ FIELDS ------------------------------

// --------------------- Interface FlushEntityEventListener ---------------------

public void onFlushEntity(FlushEntityEvent flushEntityEvent) throws HibernateException
{
super.onFlushEntity(flushEntityEvent);
// i construct audit entity using the flush event
Audit audit = this.constructAudit(p_flushEntityEvent);

flushEntityEvent.getSession().persist(audit);

}

My question is - is it valid to invoke persist within a Listener ?
I am getting
[i][b]org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session [/b][/i]
when persisting audit entity

I have a junit test class which has several test methods. When I execute test method individually, i dont get this execption. But when i execute the whole test class, then i get this exeception.

Did you face such problem with listeners?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.