hql中列表参数的正确格式是什么

what is correct format for list param in hql

RaceRegistration.executeQuery("select RaceRegistration.compositeEvent.id FROM RaceRegistration where RaceRegistration.id in :registrationIds group by RaceRegistration.compositeEvent.id",
                     [registrationIds: [1,2]])

在上面的查询中,我的疑问在最后一部分 [registrationIds: [1,2]]。这里我假设列表的格式是错误的。感谢您在更正格式方面提供的任何帮助。谢谢!

我得到以下异常

Exception thrown

org.springframework.orm.hibernate3.HibernateQueryException: Unable to resolve path [RaceRegistration.compositeEvent], unexpected token [RaceRegistration] [select RaceRegistration.compositeEvent.id FROM com.runnercard.registration.RaceRegistration where RaceRegistration.id in :registrationIds group by RaceRegistration.compositeEvent.id]; nested exception is org.hibernate.QueryException: Unable to resolve path [RaceRegistration.compositeEvent], unexpected token [RaceRegistration] [select RaceRegistration.compositeEvent.id FROM com.runnercard.registration.RaceRegistration where RaceRegistration.id in :registrationIds group by RaceRegistration.compositeEvent.id]

    at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:656)

    at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)

    at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)

    at org.springframework.orm.hibernate3.HibernateTemplate.executeFind(HibernateTemplate.java:343)

    at com.runnercard.registration.RaceRegistration.executeQuery(RaceRegistration.groovy)

    at com.runnercard.registration.RaceRegistration$executeQuery.call(Unknown Source)

    at ConsoleScript5.run(ConsoleScript5:4)

Caused by: org.hibernate.QueryException: Unable to resolve path [RaceRegistration.compositeEvent], unexpected token [RaceRegistration] [select RaceRegistration.compositeEvent.id FROM com.runnercard.registration.RaceRegistration where RaceRegistration.id in :registrationIds group by RaceRegistration.compositeEvent.id]

    at org.hibernate.hql.ast.tree.IdentNode.resolveAsNakedComponentPropertyRefLHS(IdentNode.java:219)

    at org.hibernate.hql.ast.tree.IdentNode.resolve(IdentNode.java:108)

    at org.hibernate.hql.ast.tree.DotNode.resolveFirstChild(DotNode.java:175)

    at org.hibernate.hql.ast.HqlSqlWalker.lookupProperty(HqlSqlWalker.java:576)

    at org.hibernate.hql.antlr.HqlSqlBaseWalker.propertyRef(HqlSqlBaseWalker.java:1181)

    at org.hibernate.hql.antlr.HqlSqlBaseWalker.propertyRefLhs(HqlSqlBaseWalker.java:5495)       

异常说明了其他事情。 RaceRegistration class 上的映射似乎有问题。似乎字段 compositeEvent 未映射或未正确映射。

考虑到抛出的异常,实际上你的问题是错误的。