-->
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: FYI - syntax error using HQL for certain package names
PostPosted: Thu May 11, 2006 9:26 am 
Newbie

Joined: Thu May 11, 2006 9:02 am
Posts: 1
Hi All,
I did a search around the documentation but did not find this posted. If it is, and I missed it, do point out the URL so I can read up on possible solutions.

Im using Spring with Hibernate to design a software application.
My application uses a package names that begins with in.gov.xxx.xxxx.
The "in" in the package name stands for india. Given a table User in this package, hibernate maps the object in.gov.xxx.xxxx.User -> user correctly. However, in my DAO class, Im using a simple HQL statement to fetch all users like so (in spring terminology):
getHibernateTemplate().find("from User").

In the stack trace I see the following:

Code:
org.springframework.orm.hibernate3.HibernateQueryException: expecting OPEN, found '.' near line 1, column 8 [from in.gov.xxx.xxxx.domain.User]; nested exception is org.hibernate.hql.ast.QuerySyntaxError: expecting OPEN, found '.' near line 1, column 8 [from in.gov.xxx.xxxx.domain.User]
org.hibernate.hql.ast.QuerySyntaxError: expecting OPEN, found '.' near line 1, column 8 [from in.gov.xxx.xxxx.domain.User]
        at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:63)
        at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:215)
        at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:127)
        at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
        at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:427)
        at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:884)
        at org.hibernate.impl.SessionImpl.list(SessionImpl.java:834)
        at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)


After some amount of hair pulling, I realized that the problem had to do with my package name beginning with the word "in" wihch is a keyword in hql/sql. Note the column number 8. I changed my package name to start with "ind" instead and everything worked great.

Shouldnt hibernate be able to tell that this is a package name and not a keyword given that the "." follows the word "in". If there was a space after the word "in" then I would understand.

It seems to me this might be a possible bug. Has this been reported before and if so, any workarounds other than changing package names ? Thanks,

Rohit


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 07, 2006 5:47 pm 
Newbie

Joined: Mon Nov 07, 2005 3:07 pm
Posts: 3
I ran into the selfsame exception, as a result of declaring a variable named "count". The HQL grammar *does* seem somewhat "irregular" although this is no doubt to some extent unavoidable given its SQL heritage. The most recent BNF I could find was here http://www.hibernate.org/89.html which is not only partial, but dates from Hibernate 2.x. Can anyone do better?


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.