-->
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 parameter in Hibernate 3.1
PostPosted: Mon Oct 24, 2005 10:14 am 
Newbie

Joined: Fri Sep 23, 2005 6:25 am
Posts: 6
I have the following HQL query:

select p1_1.id, p1_1.name, p1_1.dob from PatientClinical as p1_1 where (p1_1.id = :A.B)

This query works fine in Hibernate 2.

It seems that Hibernate 3.1 doesn't like "." characters within HQL named parameters.

In Hibernate 3.1 it crashes with a NPE:

java.lang.NullPointerException
org.hibernate.hql.ast.HqlSqlWalker.lookupProperty(HqlSqlWalker.java:380)
org.hibernate.hql.antlr.HqlSqlBaseWalker.addrExpr(HqlSqlBaseWalker.java:4308)
org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1211)
org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4024)
org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3513)
org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1758)
org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:776)
org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:577)
org.hibernate.hql.antlr.HqlSqlBaseWalker.collectionFunctionOrSubselect(HqlSqlBaseWalker.java:4235)
org.hibernate.hql.antlr.HqlSqlBaseWalker.inRhs(HqlSqlBaseWalker.java:4144)
org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3827)
org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1758)
org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:776)
org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:577)
org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:216)
org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:156)
org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:103)
org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:473)
org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1060)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1010)
org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
query.server.QueryRunner.runHQLQuery(QueryRunner.java:143)
query.server.QueryRunner.doGet(QueryRunner.java:104)
query.server.QueryRunner.doPost(QueryRunner.java:421)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


If I change the param name from "A.B" to "A_B" it works fine, but it doesn't help me too much because all the HQL statements are generated automatically and I can't do anything about that.

Any idea?

Many thanks,
Vasile


--------------------------------------------------------------------------------


Top
 Profile  
 
 Post subject: dots
PostPosted: Tue Oct 25, 2005 6:32 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
Yes, H does not allow dots in named parameters.
http://www.hibernate.org/250.html#A22
>it doesn't help me too much because all the HQL statements are generated automatically and I can't do anything about that.

Do you mean that some deity gave HQL to you as a scripture? :)

Why do cannot you change the code generation template? Or at least post process results and replace all the :([a-zA-Z]+)[.]([a-zA-Z]+) with value of re.getParen(1) +”_”+re.getParen(2)

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


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.