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: