Problem to query with generated columns: Illegal attempt to dereference collection [agent0_.agentid.roleSet] with element property reference [roleName_up] [from com.Agent a where a.roleSet.roleName_up = :role AND a.status not in (:status) ]

Description

This issue occurs when upgrading to version 3.2.4_sp1. It works absolutely fine with version 3.2.1 <Three similar cases fail when using Hibernate version 3.2.4.sp1.
Error:
illegal attempt to dereference collection [agent0_.agentid.roleSet] with element property reference [roleName_up] [from com.Agent a where a.roleSet.roleName_up = :role AND a.status not in (:status) ]

org.hibernate.QueryException: illegal attempt to dereference collection [agent0_.agentid.roleSet] with element property reference [roleName_up] [from com.Agent a where a.roleSet.roleName_up = :role AND a.status not in (:status) ]
at org.hibernate.hql.ast.tree.DotNode$1.buildIllegalCollectionDereferenceException(DotNode.java:46)
at org.hibernate.hql.ast.tree.DotNode.checkLhsIsNotCollection(DotNode.java:512)
at org.hibernate.hql.ast.tree.DotNode.resolve(DotNode.java:221)
at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:94)
at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:90)
at org.hibernate.hql.ast.HqlSqlWalker.resolve(HqlSqlWalker.java:728)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1216)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4041)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3525)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1762)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1687)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:776)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:577)
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:228)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
at com.DAOImp.AgentDAOImp.findAgentByCriteria(AgentDAOImp.java:388)

Agent a has a roleSet defined like this -
private Set roleSet;
@ManyToMany(targetEntity = SecurityRole.class, cascade={}, fetch= FetchType.LAZY)
@JoinTable(name="AGENTROLE", joinColumns={@JoinColumn(name="AGENTID")}, inverseJoinColumns={@JoinColumn(name="SECURITYROLEID")})
public Set getRoleSet() {
return roleSet;
}

SecurityRole has attribute roleName_up which maps to a generated column value like this.
@Column(name="roleName_up", insertable=false, updatable=false)
@Generated(value = GenerationTime.ALWAYS)
public String getRoleName_up() {
return roleName_up;
}

Environment

Hibernate 3.2.4.sp1;
Database server = DB2/LINUXX8664 9.5.0
JDK: 1.5.0_14-b03

Activity

Show:
Brett Meyer
April 7, 2014, 5:42 PM

In an effort to clean up, in bulk, tickets that are most likely out of date, we're transitioning all ORM 3 tickets to an "Awaiting Test Case" state. Please see http://in.relation.to/Bloggers/HibernateORMJIRAPoliciesAndCleanUpTactics for more information.

If this is still a legitimate bug in ORM 4, please provide either a test case that reproduces it or enough detail (entities, mappings, snippets, etc.) to show that it still fails on 4. If nothing is received within 3 months or so, we'll be automatically closing them.

Thank you!

Brett Meyer
July 8, 2014, 3:10 PM

Bulk rejecting stale issues. If this is still a legitimate issue on ORM 4, feel free to comment and attach a test case. I'll address responses case-by-case. Thanks!

Assignee

Unassigned

Reporter

Debabrata Dey

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure