Announcement Announcement Module
Collapse
No announcement yet.
Hibernate and lazy load Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Have a look at this, it explains ways to have bidirectional indexed collections:

    http://www.hibernate.org/193.html

    H3 even supports them without workarounds, also explained on that page.

    Comment


    • #17
      Thanks.

      Comment


      • #18
        An exception while query specified join fetching

        I tried to create a left join fetch of one-to-many relationship for lazy load and get an exception "query specified join fetching, but the owner of the fetched association was not present in the select list".
        The query having the exception is
        select or.orderID, or.account.customer.customerName, " +
        "or.woStatus, or.priority, or.createDate, wo.items " +
        "from Order or left join fetch or.items

        However if I query like
        from Order or left join fetch or.items

        No exception is thrown.

        What is the issue?

        Comment


        • #19
          Is it possible to post the full query you are running along with the stacktrace. [code] [ /code] tags would be nice.

          Comment


          • #20
            Re: query specified join fetching exception

            The query I used is the same as posted on the above. Here is the stacktrace. Thanks.

            org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list [FromElement{explicit,not a collection join,fetch join,fetch non-lazy properties,classAlias=null,role=product.items,tabl eName=item,tableAlias=item1_,origin=Order order0_,colums={order0_.OrderID, className=product.item}}] [select or.orderID, or.account.customer.customerName, or.woStatus, or.priority, or.createDate, or.items from Order or left join fetch or.items]
            org.hibernate.hql.ast.tree.SelectClause.initialize ExplicitSelectClause(SelectClause.java:195)
            org.hibernate.hql.ast.HqlSqlWalker.useSelectClause (HqlSqlWalker.java:705)
            org.hibernate.hql.ast.HqlSqlWalker.processQuery(Hq lSqlWalker.java:529)
            org.hibernate.hql.antlr.HqlSqlBaseWalker.query(Hql SqlBaseWalker.java:645)
            org.hibernate.hql.antlr.HqlSqlBaseWalker.selectSta tement(HqlSqlBaseWalker.java:281)
            org.hibernate.hql.antlr.HqlSqlBaseWalker.statement (HqlSqlBaseWalker.java:229)
            org.hibernate.hql.ast.QueryTranslatorImpl.analyze( QueryTranslatorImpl.java:228)
            org.hibernate.hql.ast.QueryTranslatorImpl.doCompil e(QueryTranslatorImpl.java:160)
            org.hibernate.hql.ast.QueryTranslatorImpl.compile( QueryTranslatorImpl.java:111)
            org.hibernate.engine.query.HQLQueryPlan.<init>(HQL QueryPlan.java:77)
            org.hibernate.engine.query.HQLQueryPlan.<init>(HQL QueryPlan.java:56)
            org.hibernate.engine.query.QueryPlanCache.getHQLQu eryPlan(QueryPlanCache.java:72)
            org.hibernate.impl.AbstractSessionImpl.getHQLQuery Plan(AbstractSessionImpl.java:133)
            org.hibernate.impl.AbstractSessionImpl.createQuery (AbstractSessionImpl.java:112)
            org.hibernate.impl.SessionImpl.createQuery(Session Impl.java:1623)
            org.hibernate.ejb.AbstractEntityManagerImpl.create Query(AbstractEntityManagerImpl.java:92)
            org.jboss.ejb3.entity.TransactionScopedEntityManag er.createQuery(TransactionScopedEntityManager.java :134)
            sun.reflect.GeneratedMethodAccessor168.invoke(Unkn own Source)
            sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
            java.lang.reflect.Method.invoke(Method.java:597)
            org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:112)
            org.jboss.ejb3.interceptor.InvocationContextImpl.p roceed(InvocationContextImpl.java:166)
            org.jboss.ejb3.interceptor.EJB3InterceptorsInterce ptor.invoke(EJB3InterceptorsInterceptor.java:63)
            org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
            org.jboss.ejb3.entity.TransactionScopedEntityManag erInterceptor.invoke(TransactionScopedEntityManage rInterceptor.java:54)
            org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
            org.jboss.ejb3.AllowedOperationsInterceptor.invoke (AllowedOperationsInterceptor.java:47)
            org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
            org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxP olicy.java:126)
            org.jboss.aspects.tx.TxInterceptor$Required.invoke (TxInterceptor.java:195)
            org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
            org.jboss.aspects.tx.TxPropagationInterceptor.invo ke(TxPropagationInterceptor.java:76)
            org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
            org.jboss.ejb3.stateless.StatelessInstanceIntercep tor.invoke(StatelessInstanceInterceptor.java:62)
            org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
            org.jboss.aspects.security.AuthenticationIntercept or.invoke(AuthenticationInterceptor.java:77)
            org.jboss.ejb3.security.Ejb3AuthenticationIntercep tor.invoke(Ejb3AuthenticationInterceptor.java:106)
            org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
            org.jboss.ejb3.ENCPropagationInterceptor.invoke(EN CPropagationInterceptor.java:46)
            org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
            org.jboss.ejb3.asynchronous.AsynchronousIntercepto r.invoke(AsynchronousInterceptor.java:106)
            org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
            org.jboss.ejb3.stateless.StatelessContainer.dynami cInvoke(StatelessContainer.java:278)
            org.jboss.ejb3.remoting.IsLocalInterceptor.invokeL ocal(IsLocalInterceptor.java:79)
            org.jboss.ejb3.remoting.IsLocalInterceptor.invoke( IsLocalInterceptor.java:70)
            org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
            org.jboss.ejb3.stateless.StatelessRemoteProxy.invo ke(StatelessRemoteProxy.java:103)
            $Proxy248.query(Unknown Source)
            sun.reflect.GeneratedMethodAccessor167.invoke(Unkn own Source)
            sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
            java.lang.reflect.Method.invoke(Method.java:597)
            org.springframework.aop.support.AopUtils.invokeJoi npointUsingReflection(AopUtils.java:281)
            org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:199)
            $Proxy249.query(Unknown Source)
            product.collectAllOrders(OrderManagerBean.java:136 )
            sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
            sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
            sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
            java.lang.reflect.Method.invoke(Method.java:597)
            org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:112)
            org.jboss.ejb3.interceptor.InvocationContextImpl.p roceed(InvocationContextImpl.java:166)
            org.jboss.ejb3.interceptor.EJB3InterceptorsInterce ptor.invoke(EJB3InterceptorsInterceptor.java:63)
            org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
            org.jboss.ejb3.entity.TransactionScopedEntityManag erInterceptor.invoke(TransactionScopedEntityManage rInterceptor.java:54)
            org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
            org.jboss.ejb3.AllowedOperationsInterceptor.invoke (AllowedOperationsInterceptor.java:47)
            org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
            org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPoli cy.java:79)
            org.jboss.aspects.tx.TxInterceptor$Required.invoke (TxInterceptor.java:191)
            org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
            org.jboss.aspects.tx.TxPropagationInterceptor.invo ke(TxPropagationInterceptor.java:76)
            org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
            org.jboss.ejb3.stateless.StatelessInstanceIntercep tor.invoke(StatelessInstanceInterceptor.java:62)
            org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
            org.jboss.aspects.security.AuthenticationIntercept or.invoke(AuthenticationInterceptor.java:77)
            org.jboss.ejb3.security.Ejb3AuthenticationIntercep tor.invoke(Ejb3AuthenticationInterceptor.java:106)
            org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
            org.jboss.ejb3.ENCPropagationInterceptor.invoke(EN CPropagationInterceptor.java:46)
            org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
            org.jboss.ejb3.asynchronous.AsynchronousIntercepto r.invoke(AsynchronousInterceptor.java:106)
            org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
            org.jboss.ejb3.stateless.StatelessContainer.dynami cInvoke(StatelessContainer.java:278)
            org.jboss.ejb3.remoting.IsLocalInterceptor.invokeL ocal(IsLocalInterceptor.java:79)
            org.jboss.ejb3.remoting.IsLocalInterceptor.invoke( IsLocalInterceptor.java:70)
            org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
            org.jboss.ejb3.stateless.StatelessRemoteProxy.invo ke(StatelessRemoteProxy.java:103)
            $Proxy250.collectAllWorkOrders(Unknown Source)
            sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
            sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
            sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
            java.lang.reflect.Method.invoke(Method.java:597)
            org.springframework.aop.support.AopUtils.invokeJoi npointUsingReflection(AopUtils.java:281)
            org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:199)
            $Proxy251.collectAllWorkOrders(Unknown Source)
            product.listAllOrders(ListOrderAction.java:57)
            sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
            sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
            sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
            java.lang.reflect.Method.invoke(Method.java:597)
            org.apache.struts.actions.DispatchAction.dispatchM ethod(DispatchAction.java:270)
            org.apache.struts.actions.DispatchAction.execute(D ispatchAction.java:187)
            org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:431)
            org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:236)
            org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1196)
            org.apache.struts.action.ActionServlet.doGet(Actio nServlet.java:414)
            javax.servlet.http.HttpServlet.service(HttpServlet .java:690)
            javax.servlet.http.HttpServlet.service(HttpServlet .java:803)
            org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(ReplyHeaderFilter.java:96)

            Comment


            • #21
              Hibernate and lazy load

              Last time I talked briefly about lazy associations in Hibernate, and how they could be applied to minimize unnecessary database requests. We learned how Hibernate introduces and manages lazy associations, and how you can develop to ensure that the details of these lazy connections don't trip you up. Today I want to expand on those ideas, and learn how we can optimize the lazy fetching model. You should read this previous article: Hibernate: Understanding Lazy Fetching , otherwise today's tip won't make a dollar's worth of sense.
              Celebrities Photos

              Comment

              Working...
              X