After upgrading to Hibernate 3.1.2 from 3.0 some of our HQL queries fails with an exception saying that query specified join fetching, but the owner of the fetched association was not present in the select list
Can anyone tell me what this message means?
One of he failing queries is included below.
Kind regards
Claus Nielsen
Hibernate version:
3.1.2
(Partial) Mapping documents:
<class name="com.bmd.bs400.file.Kunde" table="KUNDEL1" lazy="true" >
<meta attribute="implement-equals">true</meta>
<meta attribute="extra-import" inherit="false">com.bmd.bs400.file.Abonnement</meta>
<id name="kundenr" column="AJAENB" type="com.bmd.bs400.hibernate.KundenrUserType">
<meta attribute="use-in-equals">true</meta>
<meta attribute="use-in-tostring">true</meta>
<generator class="assigned"/>
</id>
<component name="adresse" class="com.bmd.bs400.component.Adresse">
<property name="fornavn" column="AJP1TE" type="com.bmd.bs400.hibernate.FornavnUserType">
<meta attribute="use-in-equals">true</meta>
<meta attribute="use-in-tostring">true</meta>
</property>
<property name="efternavn" column="AJP2TE" type="com.bmd.bs400.hibernate.EfternavnUserType">
<meta attribute="use-in-equals">true</meta>
<meta attribute="use-in-tostring">true</meta>
</property>
<property name="extraNavn" column="AJAEA3" type="com.bmd.bs400.hibernate.ExtraNavnUserType">
<meta attribute="use-in-equals">true</meta>
<meta attribute="use-in-tostring">true</meta>
</property>
<property name="gadeAdresse" column="AJADA3" type="com.bmd.bs400.hibernate.GadeAdresseUserType">
<meta attribute="use-in-equals">true</meta>
<meta attribute="use-in-tostring">true</meta>
</property>
<property name="stednavn" column="AJAFA3" type="com.bmd.bs400.hibernate.StednavnUserType">
<meta attribute="use-in-equals">true</meta>
<meta attribute="use-in-tostring">true</meta>
</property>
<many-to-one name="postnummer" class="com.bmd.bs400.file.Postnummer" insert="false" update="false">
<column name="AJAXCD" />
<column name="AJAICD" />
</many-to-one>
<property name="postnr" column="AJAICD" type="com.bmd.bs400.hibernate.PostnrUserType">
<meta attribute="use-in-equals">true</meta>
<meta attribute="use-in-tostring">true</meta>
</property>
<property name="landekode" column="AJAXCD" type="com.bmd.bs400.hibernate.LandekodeUserType">
<meta attribute="use-in-equals">true</meta>
<meta attribute="use-in-tostring">true</meta>
</property>
</component>
</class>
<class name="com.bmd.bs400.file.Postnummer" table="POSTN2L2" lazy="true" >
<meta attribute="implement-equals">true</meta>
<composite-id name="postnummerPK" class="com.bmd.bs400.file.PostnummerPK">
<key-property name="landekode" column="ATAXCD"
type="com.bmd.bs400.hibernate.LandekodeUserType">
<meta attribute="use-in-equals">true</meta>
<meta attribute="use-in-tostring">true</meta>
</key-property>
<key-property name="postnr" column="ATAICD"
type="com.bmd.bs400.hibernate.PostnrUserType">
<meta attribute="use-in-equals">true</meta>
<meta attribute="use-in-tostring">true</meta>
</key-property>
</composite-id>
<many-to-one name="land" class="com.bmd.bs400.file.Land"
insert="false" update="false">
<meta attribute="use-in-equals">false</meta>
<meta attribute="use-in-tostring">false</meta>
<column name="ATAXCD" />
</many-to-one>
<property name="postdistrikt" column="ATABA3"
type="com.bmd.bs400.hibernate.PostdistriktUserType">
</property>
</class>
<class name="com.bmd.bs400.file.Land" table="LANDL3" lazy="true">
<meta attribute="implement-equals">true</meta>
<id name="landekode" column="BOAXCD" type="com.bmd.bs400.hibernate.LandekodeUserType">
<meta attribute="use-in-equals">true</meta>
<meta attribute="use-in-tostring">true</meta>
<generator class="assigned" />
</id>
<property name="landenavn" column="BOAAA3"
type="com.bmd.bs400.hibernate.LandenavnUserType">
</property>
</class>
Code between sessionFactory.openSession() and session.close():
Object[] result = (Object[]) template.execute(new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException, SQLException {
Query query = session.createQuery(
"select k.adresse.fornavn, k.adresse.efternavn, k.adresse.extraNavn"
+ ", k.adresse.gadeAdresse, k.adresse.stednavn"
+ ", pn.postnummerPK.postnr, pn.postdistrikt"
+ ", land.landekode, land.landenavn"
+ " from Kunde k"
+ " left outer join fetch k.adresse.postnummer pn"
+ " left outer join fetch k.adresse.postnummer.land land"
+ " where k.kundenr = :kundenr"
+ " order by k.kundenr ");
query.setParameter("kundenr", kundenr, type(KundenrUserType.class));
return query.uniqueResult();
}
});
Full stack trace of any exception that occurs:
org.springframework.orm.hibernate3.HibernateQueryException: 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=pn,role=null,tableName=POSTN2L2,tableAlias=postnummer1_,origin=KUNDEL1 kunde0_,colums={kunde0_.AJAXCD kunde0_.AJAICD ,className=com.bmd.bs400.file.Postnummer}}] [select k.adresse.fornavn, k.adresse.efternavn, k.adresse.extraNavn, k.adresse.gadeAdresse, k.adresse.stednavn, pn.postnummerPK.postnr, pn.postdistrikt, land.landekode, land.landenavn from com.bmd.bs400.file.Kunde k left outer join fetch k.adresse.postnummer pn left outer join fetch k.adresse.postnummer.land land where k.kundenr = :kundenr order by k.kundenr ]; nested exception is 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=pn,role=null,tableName=POSTN2L2,tableAlias=postnummer1_,origin=KUNDEL1 kunde0_,colums={kunde0_.AJAXCD kunde0_.AJAICD ,className=com.bmd.bs400.file.Postnummer}}] [select k.adresse.fornavn, k.adresse.efternavn, k.adresse.extraNavn, k.adresse.gadeAdresse, k.adresse.stednavn, pn.postnummerPK.postnr, pn.postdistrikt, land.landekode, land.landenavn from com.bmd.bs400.file.Kunde k left outer join fetch k.adresse.postnummer pn left outer join fetch k.adresse.postnummer.land land where k.kundenr = :kundenr order by k.kundenr ]
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=pn,role=null,tableName=POSTN2L2,tableAlias=postnummer1_,origin=KUNDEL1 kunde0_,colums={kunde0_.AJAXCD kunde0_.AJAICD ,className=com.bmd.bs400.file.Postnummer}}] [select k.adresse.fornavn, k.adresse.efternavn, k.adresse.extraNavn, k.adresse.gadeAdresse, k.adresse.stednavn, pn.postnummerPK.postnr, pn.postdistrikt, land.landekode, land.landenavn from com.bmd.bs400.file.Kunde k left outer join fetch k.adresse.postnummer pn left outer join fetch k.adresse.postnummer.land land where k.kundenr = :kundenr order by k.kundenr ]
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 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.springframework.orm.hibernate3.HibernateTemplate$CloseSuppressingInvocationHandler.invoke(HibernateTemplate.java:1183)
at $Proxy32.createQuery(Unknown Source)
at com.bmd.bs400.dao.SelfServiceDaoImpl$1.doInHibernate(SelfServiceDaoImpl.java:164)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:366)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:334)
at com.bmd.bs400.dao.SelfServiceDaoImpl.hentKundeoplysninger(SelfServiceDaoImpl.java:162)
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.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:287)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
at com.bmd.dao.interceptor.AbstractSchemaSelector.invoke(AbstractSchemaSelector.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
at $Proxy29.hentKundeoplysninger(Unknown Source)
at com.bmd.bs400.dao.SelfServiceDaoTest.testRetKundeoplysninger_validering(SelfServiceDaoTest.java:74)
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 junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Name and version of the database you are using:
DB2/400 (driver is JTOpen 5.0)
The generated SQL (show_sql=true):
n/a
Debug level Hibernate log excerpt:
Last edited by clanie on Thu Mar 09, 2006 7:25 am, edited 1 time in total.
|