-->
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.  [ 3 posts ] 
Author Message
 Post subject: HQL fails regading select fields position
PostPosted: Thu Jul 21, 2011 5:53 am 
Newbie

Joined: Thu Jul 21, 2011 5:43 am
Posts: 4
Hi,

I'm using Hibernate 3.6.3.

Executing the following queries:


1. FAIL
Code:
select client, quantityOnHand from ProductStockView

2. FAIL
Code:
select client as c, quantityOnHand as q from ProductStockView

3. OK
Code:
select quantityOnHand, client from ProductStockView

4. OK
Code:
select p.client, p.quantityOnHand from ProductStockView as p


Regardless actual mappings, how is it possible #1 to fail and #3 to work, when the only difference between them is the order in the fields in the select clause?

Why #4 which is exactly the same as #1 but adding an alias to the entity works?

The exception I get in the cases of failure is:

Code:
org.openbravo.service.datasource.DataSourceServlet - No data type for node: org.hibernate.hql.ast.tree.IdentNode
\-[IDENT] IdentNode: 'quantityOnHand' {originalText=quantityOnHand}

java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.tree.IdentNode
\-[IDENT] IdentNode: 'quantityOnHand' {originalText=quantityOnHand}

    at org.hibernate.hql.ast.tree.SelectClause.initializeExplicitSelectClause(SelectClause.java:156)
    at org.hibernate.hql.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:857)
    at org.hibernate.hql.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:645)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:685)
    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.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
    at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
    at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1770)


Thanks is advance!

Asier


Top
 Profile  
 
 Post subject: Re: HQL fails regading select fields position
PostPosted: Fri Aug 19, 2011 12:04 pm 
Newbie

Joined: Tue Aug 16, 2011 5:58 pm
Posts: 6
alostale wrote:
Hi,

I'm using Hibernate 3.6.3.

Executing the following queries:


1. FAIL
Code:
select client, quantityOnHand from ProductStockView

2. FAIL
Code:
select client as c, quantityOnHand as q from ProductStockView

3. OK
Code:
select quantityOnHand, client from ProductStockView

4. OK
Code:
select p.client, p.quantityOnHand from ProductStockView as p


Regardless actual mappings, how is it possible #1 to fail and #3 to work, when the only difference between them is the order in the fields in the select clause?

Why #4 which is exactly the same as #1 but adding an alias to the entity works?

The exception I get in the cases of failure is:

Code:
org.openbravo.service.datasource.DataSourceServlet - No data type for node: org.hibernate.hql.ast.tree.IdentNode
\-[IDENT] IdentNode: 'quantityOnHand' {originalText=quantityOnHand}

java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.tree.IdentNode
\-[IDENT] IdentNode: 'quantityOnHand' {originalText=quantityOnHand}

    at org.hibernate.hql.ast.tree.SelectClause.initializeExplicitSelectClause(SelectClause.java:156)
    at org.hibernate.hql.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:857)
    at org.hibernate.hql.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:645)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:685)
    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.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
    at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
    at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1770)


Thanks is advance!

Asier


Asier, you basically answered your own questions as it seems you just are kind of working guess and check in to the commands. now that you know what works just continue on that path. That is how I taught myself to conduct online file storage tactics optimized for IT and it has been a great learning method as I prepare my resume for an IT staffing service. Wish me luck on the job hunt, otherwise hit me up if you wanna talk computing in any way shape or form.


Last edited by grizzkeys on Wed Dec 28, 2011 3:01 pm, edited 3 times in total.

Top
 Profile  
 
 Post subject: Re: HQL fails regading select fields position
PostPosted: Mon Aug 22, 2011 3:01 pm 
Newbie

Joined: Thu Jul 21, 2011 5:43 am
Posts: 4
Hi Grizzkeys,

Of course now is not a stopper as I can continue using the query that works. But in any case it looked strange to me, so I posted here just to confirm whether it is a bug.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.