Catching javax.persistence.NoResultException
457351Feb 14 2007 — edited Feb 15 2007Greetings to all,
I have done a Java Client in order to test my Stateless Facade Bean, but the problem is when i invoke a method for get a named query results, it to throws the exception "javax.persistence.NoResultException", i'm trying to catch it but is not possible, anyhow the exception is propagated.
My source code for the Java cliente is:
try {
myobject = (MyClass) em.createNamedQuery("myquerymethod").setParameter("parameter1", value).getSingleResult();
return myobject;
}
catch (NoResultException e) {
return usr;
}
--------------- Output generated in the log window ----------------------------------------
Feb 14, 2007 6:14:37 PM com.evermind.server.ejb.logging.EJBMessages logException
SEVERE: [myFacade:public org.mypackage.persistence.myclass org.mypackage.model.myFacadeBean.myquerymethod(java.lang.String)] exception occurred during method invocation: oracle.oc4j.rmi.OracleRemoteException: javax.persistence.NoResultException: getSingleResult() did not retrieve any entities.; nested exception is:
javax.persistence.NoResultException: getSingleResult() did not retrieve any entities.
------------------------------------------------------------------------------------------------------------
Do you know why can i not catch the exception ?
Thanks in advance