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