-->
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.  [ 4 posts ] 
Author Message
 Post subject: Why "path expression ends in a composite value" er
PostPosted: Thu Jan 20, 2005 9:34 am 
Beginner
Beginner

Joined: Wed Dec 08, 2004 9:17 am
Posts: 25
Hi all,

I am trying to run the following query in Hibernate
Code:
List results = getHibernateTemplate().find("from VersionImpl as v where v.id=? AND v.workspaceId=?", new Object[]{new Integer(headVersionId), new Integer(workspaceId)});


The mapping for VersionImpl is as follows:
Code:
<hibernate-mapping schema="dbo" package="de.vodafone.rnp.core.business.persistence.hibernate">
    <class name="VersionImpl" table="funver" proxy="VersionImpl" lazy="true">
        <composite-id>
            <key-property name="id" type="integer" column="ver_nr"/>
            <key-property name="workspaceId" type="integer" column="arb_lfdnr"/>
        </composite-id>
        <property name="name" type="string" column="ver_name"/>
        <property name="creationDate" type="date" column="ver_ang_zeit"/>
        <property name="inconsistent" type="boolean" column="ver_loesch_jn"/>
        <property name="comment" type="string" column="ver_kommentar"/>

        <set name="cellGroups" lazy="true" inverse="true">
            <key>
                <column name="arb_lfdnr"/>
                <column name="ver_nr"/>
            </key>
            <one-to-many class="CellGroupImpl"/>
        </set>
        <many-to-one name="workspace" class="WorkspaceImpl" column="arb_lfdnr" insert="false" update="false"/>
    </class>
</hibernate-mapping>


Hibernate throws a QueryException because its PathExpressionParser has 2 entries in its "columns" collection (Which sounds ok for me since I am searching over 2 columns, the column containing the id and the colum containing the workspaceId).
Code:
main 20.01.2005 13:53:32.423 [DEBUG]    net.sf.hibernate.impl.SessionImpl find: from VersionImpl as v where v.id=? AND v.workspaceId=? 
main 20.01.2005 13:53:32.429 [DEBUG]    net.sf.hibernate.engine.QueryParameters parameters: [0, 14] 
main 20.01.2005 13:53:32.436 [DEBUG]    net.sf.hibernate.engine.QueryParameters named parameters: {} 
main 20.01.2005 13:53:32.520 [DEBUG]    net.sf.hibernate.hql.QueryTranslator compiling query 
main 20.01.2005 14:05:45.800 [DEBUG]    org.springframework.transaction.support.TransactionSynchronizationManager Retrieved value [org.springframework.orm.hibernate.SessionHolder@179b7b0] for key [net.sf.hibernate.impl.SessionFactoryImpl@7ec028] bound to thread [main] 
Exception in thread "main" org.springframework.orm.hibernate.HibernateQueryException: path expression ends in a composite value: versionimp0_.id [from de.vodafone.rnp.core.business.persistence.hibernate.VersionImpl as v where v.id=? AND v.workspaceId=?]; nested exception is net.sf.hibernate.QueryException: path expression ends in a composite value: versionimp0_.id [from de.vodafone.rnp.core.business.persistence.hibernate.VersionImpl as v where v.id=? AND v.workspaceId=?]
net.sf.hibernate.QueryException: path expression ends in a composite value: versionimp0_.id [from de.vodafone.rnp.core.business.persistence.hibernate.VersionImpl as v where v.id=? AND v.workspaceId=?]
   at net.sf.hibernate.hql.PathExpressionParser.getWhereColumn(PathExpressionParser.java:375)
   at net.sf.hibernate.hql.WhereParser.doPathExpression(WhereParser.java:352)


What am I doing wrong?

Any suggestions?

Thanks,

Oliver



Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 20, 2005 9:38 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
id is a reserved word in HQL. rename your property and use the individual key-properties for querying.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 20, 2005 9:44 am 
Beginner
Beginner

Joined: Wed Dec 08, 2004 9:17 am
Posts: 25
Hi Michael,

I have no problems with properties named "id" in other cases regarding Hibernate. It works perfectly for querying objects that don't have composite ids (though I don't know if the problem I described in this post is related to the fact that the class VersionImpl has a composite id).

What do you mean by "use the individual key-properties for querying"? What would such a query look like? I really don't get it.

Thanks in advance!

Cheers,

Oliver


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 20, 2005 10:29 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
from Blabla b where b.primaryKey1 = ? and b.primaryKey2 = ?

id is an alias for the identifier, which is no problem when the id property is named id, but a problem if other properties are named id.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.