-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: HQL named parameters cant go deeper than 1 level in object?
PostPosted: Thu Feb 23, 2006 3:52 pm 
Newbie

Joined: Fri Mar 11, 2005 7:22 pm
Posts: 10
Hibernate 3.1

I am using HQL with a Where statement like this.
Code:
FROM classPath.ProjectMeeting pm
WHERE 1=1 AND pm.meetingDate < :meetingDate.startDate


I then create the query and then do a query.setProperties(searchParam)

SearchParam is an object that has
Code:
String title
DateParameter meetingDate
...


DateParameter is an object that has
Code:
int searchMode
Date startDate
Date endDate


When this occurs, I get the following exception
Code:
15126 [main] DEBUG org.hibernate.hql.ast.ErrorCounter  - throwQueryException() : no errors
15204 [main] DEBUG org.hibernate.hql.antlr.HqlSqlBaseWalker  - select << begin [level=1, statement=select]
15251 [main] DEBUG org.hibernate.hql.ast.tree.FromElement  - FromClause{level=1} :  com.agensys.projectmanagement.model.ProjectMeeting (pm) -> projectmee0_
15266 [main] DEBUG org.hibernate.hql.ast.tree.FromReferenceNode  - Resolved :  pm -> projectmee0_.meeting_id
15266 [main] DEBUG org.hibernate.hql.ast.tree.DotNode  - getDataType() : title -> org.hibernate.type.StringType@1397e5c
15266 [main] DEBUG org.hibernate.hql.ast.tree.FromReferenceNode  - Resolved :  pm.title -> projectmee0_.title
15266 [main] DEBUG org.hibernate.hql.ast.tree.FromReferenceNode  - Resolved :  pm -> projectmee0_.meeting_id
15282 [main] DEBUG org.hibernate.hql.ast.tree.DotNode  - getDataType() : meetingDateTime -> org.hibernate.type.TimestampType@3a0ab1
15282 [main] DEBUG org.hibernate.hql.ast.tree.FromReferenceNode  - Resolved :  pm.meetingDateTime -> projectmee0_.meeting_timestamp
15282 [main] ERROR org.hibernate.hql.PARSER  - <AST>:1:130: unexpected AST node: :
15282 [main] DEBUG org.hibernate.hql.ast.ErrorCounter  - <AST>:1:130: unexpected AST node: :
<AST>:1:130: unexpected AST node: :
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.addrExpr(HqlSqlBaseWalker.java:4367)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.addrExprLhs(HqlSqlBaseWalker.java:4787)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.addrExpr(HqlSqlBaseWalker.java:4291)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1209)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4022)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3559)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1756)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1684)
   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)
   at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:158)
   at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:105)
   at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:74)
   at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:53)
   at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
   at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:108)
   at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:88)
   at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1540)
...


If I change the SearchParam to hold a date instead of an object that holds the date.
Code:
String title
DateParameter meetingDate
Date myDate
...


Then execute the HQL
Code:
FROM classPath.ProjectMeeting pm
WHERE 1=1 AND pm.meetingDate < :myDate

The HQL works.
Is there a limit to using named parameters, and referencing them within mutple nested objects?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 24, 2006 12:56 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Yes. Named parameters do not support and form of dot notation. A named parameter can be a mapped object, but if you want to access members of that object in the query, you'll have to put the relevant members into their own named parameters.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.