1 Reply Latest reply on Dec 3, 2009 11:41 PM by Matt Davis

    NoResultException in EntityQuery on a count query

    Matt Davis Newbie

      In the initResultCount method in EntityQuery, it is creating a count query.


      The query comes out as:




      select count(p) from com.package.Person p where (p.createdBy = 'user' or p.restricted = 0)





      Then it does a query.getSingleResult() and throws a javax.persistence.NoResultException



      How can there be no result in a count query? Could this be caused by a problem with the mapping on the Person class?

        • 1. Re: NoResultException in EntityQuery on a count query
          Matt Davis Newbie


          java.lang.RuntimeException: Could not evaluate result expression: people.resultCount
               at org.granite.tide.seam.AbstractSeamServiceContext.evaluateResults(AbstractSeamServiceContext.java:823)
               at org.granite.tide.seam.TideInterceptor.aroundInvoke(TideInterceptor.java:237)
               at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
               at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
               at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
               at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:97)
               at org.jboss.seam.util.Work.workInTransaction(Work.java:47)
               at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:91)
               at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
               at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
               at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
               at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
               at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
               at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
               at com.package.service.PeopleQuery_$$_javassist_seam_2.refresh(PeopleQuery_$$_javassist_seam_2.java)
               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
               at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
               at java.lang.reflect.Method.invoke(Unknown Source)
               at org.granite.messaging.service.ServiceInvocationContext.invoke(ServiceInvocationContext.java:71)
               at org.granite.messaging.service.security.AbstractSecurityService.endAuthorization(AbstractSecurityService.java:42)
               at org.granite.seam21.security.Seam21SecurityService.authorize(Seam21SecurityService.java:108)
               at org.granite.messaging.service.ServiceInvoker.invoke(ServiceInvoker.java:144)
               at org.granite.messaging.amf.process.AMF3MessageProcessor.processRemotingMessage(AMF3MessageProcessor.java:136)
               at org.granite.messaging.amf.process.AMF3MessageProcessor.process(AMF3MessageProcessor.java:59)
               at org.granite.messaging.amf.process.AMF0MessageProcessor.process(AMF0MessageProcessor.java:71)
               at org.granite.messaging.webapp.AMFMessageServlet.doPost(AMFMessageServlet.java:59)
               at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
               at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
               at org.granite.messaging.webapp.AMFMessageFilter.doFilter(AMFMessageFilter.java:100)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
               at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
               at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
               at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
               at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
               at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
               at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
               at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
               at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
               at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
               at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
               at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
               at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
               at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
               at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:905)
               at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:592)
               at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:2036)
               at java.lang.Thread.run(Unknown Source)
          Caused by: javax.persistence.NoResultException: No entity found for query
               at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:104)
               at org.jboss.seam.framework.EntityQuery.initResultCount(EntityQuery.java:135)
               at org.jboss.seam.framework.EntityQuery.getResultCount(EntityQuery.java:126)
               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
               at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
               at java.lang.reflect.Method.invoke(Unknown Source)
               at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
               at org.granite.tide.seam.AbstractSeamServiceContext.evaluateResults(AbstractSeamServiceContext.java:787)
               ... 52 moreing instructions. Then edit this text and check the preview.