收到此错误:非法尝试取消引用收集[{synthetic-alias} {non-qualified-property-ref} gcmUsers]

时间:2013-10-09 10:23:33

标签: hibernate hql

我在hibernate中有多对多关系表GcmUser和GroupName。

我的查询是:

from GcmUser
where clientName='admin'
and  id IN
(
    SELECT id
    FROM GroupName
    WHERE id =
        (
            SELECT id
            FROM GroupName
            WHERE groupName = 'Multy'
            AND gcmUsers.userName ='niraj'
        )
)
order by createdDateTime asc

我收到错误:illegal attempt to dereference collection [{synthetic-alias}{non-qualified-property-ref}gcmUsers] with element property reference [userName]

完整堆栈跟踪:

org.hibernate.QueryException: illegal attempt to dereference collection [{synthetic-alias}{non-qualified-property-ref}gcmUsers] with element property reference [userName] [select count(*) as totalcount  from com.bonrix.gcm.demo.model.GcmUser where clientName='admin'and  id IN(SELECT id FROM com.bonrix.gcm.demo.model.GroupName WHERE id =(SELECT id FROM com.bonrix.gcm.demo.model.GroupName WHERE groupName = 'Multy' AND gcmUsers.userName ='gadia'))]
    at org.hibernate.hql.internal.ast.tree.DotNode$1.buildIllegalCollectionDereferenceException(DotNode.java:68)
    at org.hibernate.hql.internal.ast.tree.DotNode.checkLhsIsNotCollection(DotNode.java:550)
    at org.hibernate.hql.internal.ast.tree.DotNode.resolve(DotNode.java:246)
    at org.hibernate.hql.internal.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:118)
    at org.hibernate.hql.internal.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:114)
    at org.hibernate.hql.internal.ast.HqlSqlWalker.resolve(HqlSqlWalker.java:881)
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1264)
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4297)
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3769)
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1947)

我无法理解错误的含义。为什么会出现??????

0 个答案:

没有答案