-->
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.  [ 1 post ] 
Author Message
 Post subject: Bug in HQL code?
PostPosted: Thu Sep 01, 2011 11:01 am 
Newbie

Joined: Thu Sep 01, 2011 10:44 am
Posts: 1
I have written several HQL queries for my application, such as this one: <query name="States.PrimaryKey">from States where Name = ?</query> to retrieve Primary Keys from tables so that I can store them in a table that is loaded with Foreign Keys. However, the following query: <query name="ActionType.PrimaryKey">from ActionType where ActionType = ?</query> generates the following exception:

Exception in thread "main" java.lang.ExceptionInInitializerError
at gov.nrc.wbl.reader.DataReader.main(DataReader.java:78)
Caused by: java.lang.NullPointerException
at org.hibernate.hql.ast.util.SessionFactoryHelper.findSQLFunction(SessionFactoryHelper.java:364)
at org.hibernate.hql.ast.tree.IdentNode.getDataType(IdentNode.java:293)
at org.hibernate.hql.ast.tree.BinaryLogicOperatorNode.extractDataType(BinaryLogicOperatorNode.java:232)
at org.hibernate.hql.ast.tree.BinaryLogicOperatorNode.initialize(BinaryLogicOperatorNode.java:58)
at org.hibernate.hql.ast.HqlSqlWalker.prepareLogicOperator(HqlSqlWalker.java:1199)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:4414)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2047)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:831)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:617)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:301)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:244)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:254)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:124)
at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:549)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:413)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1872)
at gov.nrc.wbl.persistence.DataPersister.<clinit>(DataPersister.java:28)
... 1 more


If I change the query to read like this:

<query name="ActionType.PrimaryKey">from ActionType where actionType = ?</query>

it works fine. I ran the following SQL against my database and, as expected, both queries returned the same data:

select * from Radmat.dbo.ActionType where ActionType = 'Renewal';
select * from Radmat.dbo.ActionType where actionType = 'Renewal';

What's confusing to me is this: the first query references TableName/ColumnName but the second query references Object/Field. I thought Hibernate abstracted away that difference when using HQL. What am I not understanding, or is this a bug?


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

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.