-->
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.  [ 4 posts ] 
Author Message
 Post subject: Catching an exception thrown by an EntityListener
PostPosted: Mon Aug 07, 2006 2:58 pm 
Regular
Regular

Joined: Wed Jan 11, 2006 12:49 pm
Posts: 64
Location: Campinas, Brazil
Hello, guys
I am trying to deal with exceptions thrown by an entity listener, more specifically in order to create som default validation device. Anyway, spec section 3.5.6 says that a lifecycle callback entity listener may throw a RuntimeException. My intention is to throw an @ApplicationException-annotated exception and catch it. My problems start because I would have to catch it during flush time, which occurs after the business method (in the case of a session EJB) finishes. So it is of no use to enclose the method in a try/catch block. I tried flushing the EntityManager at the end of my business method, but some problems happened when I performed calls to other business methods in the same transaction.
So, is there a way to create a "flush listener", or in some other way catch some exception before it goes all the way up to the client?

Henrique

_________________
Henrique Sousa
Don't forget to rate useful responses


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 10, 2006 10:28 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
wraping an explicit em.flush() was the way to go, what was your issues with that?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 11, 2006 7:26 am 
Regular
Regular

Joined: Wed Jan 11, 2006 12:49 pm
Posts: 64
Location: Campinas, Brazil
I though I had seen an exception when flushing EntityManagers in different session EJBs but the same transaction, but a co-worker just confirmed that the double flush was not the problem.
Which raises another question, just to make sure I understand things: do two EntityManagers in the same EJB transaction share the same underlying Hibernate Session?

_________________
Henrique Sousa
Don't forget to rate useful responses


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 11, 2006 1:52 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
2 injected EM from the same persistence unit share the same underlying session

_________________
Emmanuel


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