Hi,
I have a query that works under 3.0, and now fails with a parse error under 3.1
The query is "from com.test.User user where user.contacts.pCard = ? or ? in elements(user.contacts.bCards)"
contacts is a collection, and pCard is a single entity.
If I remove the pCard portion, it fails (with the same reason) on the bCards bit which is a collection.
The query should find all users that have a contact in their contacts collection that have a pCard equal to the one I substitute into the query, or, a bCard that is equal to the card I pass in.
Is this query fundementally wrong (I don't think so).
I found the change in cvs:
http://cvs.sourceforge.net/viewcvs.py/h ... 1.7&r2=1.8
I think a legitimate problem was trying to be solved, but was solved incorrectly.
Hibernate version: 3.1
Code between sessionFactory.openSession() and session.close():
Object[] params = new Object[2];
params[0] = card;
params[1] = card;
return getHibernateTemplate().find("from com.test.User user where user.contacts.pCard = ? or ? in elements(user.contacts.bCards)", params);
Full stack trace of any exception that occurs:
Caused by: illegal syntax near collection: pCard
at org.hibernate.hql.ast.tree.DotNode.checkLhsIsNotCollection(DotNode.java:474)
at org.hibernate.hql.ast.tree.DotNode.resolve(DotNode.java:193)
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:660)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1213)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4022)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3508)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1756)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1706)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:774)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:575)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:279)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:227)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:218)
Name and version of the database you are using:
MySQL 5.0
The generated SQL (show_sql=true):
none - doesn't parse