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