aspose file tools
The moose likes JBoss and the fly likes How to catch EntityNotFoundException Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Products » JBoss
Reply Bookmark "How to catch EntityNotFoundException " Watch "How to catch EntityNotFoundException " New topic
Author

How to catch EntityNotFoundException

Roland Barcia
author
Ranch Hand

Joined: Apr 15, 2004
Posts: 177
It seems that if I execute an EJB 3 query with JBoss and it returns an empty resultset, I cannot catch EntityNotFoundException. It seems that an aspect intercepts somewhere and does not allow me to respond.

I need to be able to detect in the session if the entity exist. If it does I update it. If not, I create a new one. I am testing the if not part but I can never get past EntityNotFoundException even if I catch it from the component calling the query.

Oh horray for aspect


Roland Barcia<br />STSM - ISSW Lead Web 2.0 Architect
norman richards
Author
Ranch Hand

Joined: Jul 21, 2003
Posts: 364
What do you mean "cannot catch" it? JBoss certainly throws it and it doesn't get caught by anything else. Here's a method I wrote just last week:



I this is the case because I forgot to think about the case when the application starts and there are no inventory items to sum. I was getting EntityNotFoundExceptions.
[ July 26, 2005: Message edited by: norman richards ]

[<a href="http://members.capmac.org/~orb/blog.cgi" target="_blank" rel="nofollow">blog</a>] [<a href="http://www.amazon.com/exec/obidos/ASIN/0596100078/orb-20" target="_blank" rel="nofollow">JBoss: A Developer's Notebook</a>] [<a href="http://www.amazon.com/exec/obidos/ASIN/1932394052/orb-20" target="_blank" rel="nofollow">XDoclet in Action</a>]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: How to catch EntityNotFoundException
 
Similar Threads
EntityManager.getReference method
NoSuchObjectException or EntityNotFoundException
EJB3-NoResultException
JPA exceptions and JTA rollback
javax. persistence. NoResultException