-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: Hibernate 3.1 Updrade: Error in Named Query
PostPosted: Wed Dec 21, 2005 4:15 pm 
Beginner
Beginner

Joined: Tue Nov 15, 2005 6:56 pm
Posts: 39
Using Hibernate3.1, Hibernate-tools3.1-beta2, Oracle 10g.


I'm getting an error when processing a named query in one of my mapping files. I'm attempting to upgrade from Hibernate 3.0 to 3.1. This used to work in the old version. The exception occurs as I'm starting up my app in JBOSS server as a service. Anybody have any ideas what the error means? Thanks.

Here is the exception:

Code:
Error in named query: TagClass.GetTagValue
org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list (mycompany.Tag -> mycompany.TagClass) [
   
         select tag.value
          from mycompany.TagClass tagClass
          join fetch tagClass.tag tag
          where tagClass.collClass.collClassId = :collClassId
             and tag.tagId = :tagId
             and tagClass.status = 'active'
   
   ]
   at org.hibernate.hql.ast.tree.SelectClause.initializeExplicitSelectClause(SelectClause.java:175)
   at org.hibernate.hql.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:637)
   at org.hibernate.hql.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:466)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:643)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:279)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:227)
   at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:218)
   at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:158)
   at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:105)
   at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:74)
   at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:53)
   at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
   at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:363)
   at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:327)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1167)
   at mycompany.MyCompanyHibernateService.internalBuildSessionFactory(MyCompanyHibernateService.java:102)
   at mycompany.MyCompanyHibernateService.start(MyCompanyHibernateService.java:112)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
   at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
   at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
   at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:914)
   at $Proxy0.start(Unknown Source)
   at org.jboss.system.ServiceController.start(ServiceController.java:418)
   at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
   at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
   at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
   at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
   at $Proxy4.start(Unknown Source)
   at org.jboss.deployment.SARDeployer.start(SARDeployer.java:273)
   at org.jboss.deployment.MainDeployer.start(MainDeployer.java:964)
   at org.jboss.deployment.MainDeployer.start(MainDeployer.java:956)
   at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:775)
   at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:738)
   at sun.reflect.GeneratedMethodAccessor45.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
   at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
   at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:121)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
   at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
   at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
   at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
   at $Proxy8.deploy(Unknown Source)
   at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:325)
   at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:501)
   at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:204)
   at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:277)
   at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:272)
   at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:222)
   at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
   at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
   at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
   at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:897)
   at $Proxy0.start(Unknown Source)
   at org.jboss.system.ServiceController.start(ServiceController.java:418)
   at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
   at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
   at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
   at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
   at $Proxy4.start(Unknown Source)
   at org.jboss.deployment.SARDeployer.start(SARDeployer.java:273)
   at org.jboss.deployment.MainDeployer.start(MainDeployer.java:964)
   at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:775)
   at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:738)
   at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:722)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
   at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
   at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:121)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
   at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
   at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
   at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
   at $Proxy5.deploy(Unknown Source)
   at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:434)
   at org.jboss.system.server.ServerImpl.start(ServerImpl.java:315)
   at org.jboss.Main.boot(Main.java:195)
   at org.jboss.Main$1.run(Main.java:463)
   at java.lang.Thread.run(Thread.java:595)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 21, 2005 4:25 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
yes, that is not a valid semantic (and has never been). i added code in 3.1 to explicitly check for this. The join fetch is completely pointless; you attempt to join fetch an association whose owner isn't even being returned; semantically that makes no sense.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 21, 2005 8:47 pm 
Beginner
Beginner

Joined: Tue Nov 15, 2005 6:56 pm
Posts: 39
Thanks for the help. I assume the answer is to just use "join" vs "join fetch".


Top
 Profile  
 
 Post subject: Nearly the same problem, but using documented syntax
PostPosted: Mon Feb 13, 2006 3:37 am 
Newbie

Joined: Mon Feb 13, 2006 3:07 am
Posts: 3
Location: Czech Republic
When migrating from Hibernate 3.1RC2 to 3.1.2, we encountered same error as shown above, but using the same query scheme, as in documentation:

This hql query
Code:
select p from Person p left join fetch p.events where p.id = :pid


Throws

Code:
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=null,tableName=TIPSYS_ODDS.OPPORTUNITY_TYPES,tableAlias=opportunit3_,origin=TIPSYS_ODDS.OPPORTUNITY_TYPE_OPTIONS opportunit2_,colums={opportunit2_.OPPORTUNITY_TYPE ,className=cz.tipsport.tipsys.odds.bo.OpportunityType}}] [select eventPattern from cz.tipsport.tipsys.odds.bo.EventPattern eventPattern  left join fetch eventPattern.eventPatterns2OpportunityTypeOptions ep2otos left join fetch ep2otos.opportunityTypeOption.opportunityType where eventPattern.competition.id = 22]
   at org.hibernate.hql.ast.tree.SelectClause.initializeExplicitSelectClause(SelectClause.java:190)
   at org.hibernate.hql.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:637)
   at org.hibernate.hql.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:466)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:645)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
   at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:218)
   at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:158)
   at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:109)
   at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:75)
   at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)
   at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
   at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:134)
   at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:113)
   at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1602)
   at test.hibernate.UserManager.test(UserManager.java:84)
   at test.hibernate.UserManager.main(UserManager.java:14)


When select p is removed from query, everything works fine. I know, that this select p is redundant, but I thing it should work.

Kind regrads

Lubos Lipinsky


Top
 Profile  
 
 Post subject: Any suggestions?
PostPosted: Mon Feb 13, 2006 6:43 am 
Newbie

Joined: Mon Feb 13, 2006 3:07 am
Posts: 3
Location: Czech Republic
Any suggestions for above error?

Kind regards

Lubos Lipinsky


Top
 Profile  
 
 Post subject: Use "join" vs "join fetch"
PostPosted: Mon Feb 13, 2006 6:25 pm 
Beginner
Beginner

Joined: Tue Nov 15, 2005 6:56 pm
Posts: 39
The only solution we came up with was to use "join" vs "join fetch".


Top
 Profile  
 
 Post subject: Re: Use "join" vs "join fetch"
PostPosted: Tue Feb 14, 2006 12:47 am 
Newbie

Joined: Mon Feb 13, 2006 3:07 am
Posts: 3
Location: Czech Republic
plutonianelephant wrote:
The only solution we came up with was to use "join" vs "join fetch".


But this isn't right. The query I tried is mentioned in documentation and should work, becouse the owner is in the select clause. In my opinion "the check" if owner of the fetch join is in select doesn't work properly.

Lubos Lipinsky


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.