Why was this "bug" marked resolved?
tsar_bomba May 11, 2006 6:16 PMThis was marked as a major bug:
http://opensource.atlassian.com/projects/hibernate/browse/EJB-133
...yet it's status is "resolved". However, I still very much get this exception...it's quite simple to reproduce (not like the users who had commented on the bug in the link above.)
Simply query an object using getSingleResult() where there is no data in the table and you'll get this exception (I happen to be using MSSQL 2000):
javax.ejb.EJBException: javax.persistence.NoResultException: No entity found for query org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69) org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83) org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:192) org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76) org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54) org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78) org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47) org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106) org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98) org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:181) org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:79)
I've been skating around it by doing something like this:
public User getAuthUser(User user) { try { Query q = this.em.createQuery("select u from User u where username = :un and password = :pw"); q.setParameter("un", user.getUsername()); q.setParameter("pw", Crypto.encrypt(user.getPassword())); user = (User)q.getSingleResult(); } catch (NoResultException exp) { user = null; } return user; }
However, shouldn't it *not* be throwing an exception? I'm only assuming so since there was a bug report filed for it and it was labeled as major.
Thanks!