-->
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: Problem with HQL
PostPosted: Thu Oct 20, 2005 4:37 pm 
Newbie

Joined: Thu Oct 20, 2005 3:07 pm
Posts: 1
Hibernate version: 3.0

Name and version of the database you are using: Oracle 10

Hi,
I've writed this hql query wich is a little bit complicated,


Code:
select
   max(pg.product.productModel.subgroup.group.section.description) as sectionDescription,
   max(pg.product.productModel.subgroup.group.section.functionalNumber) as sectionFunctionalNumber,
   pg.id as id,
   max(pg.product.description) as productDescription,
   max(sup.fantasyName) as supplierName,
   sum(fii.amount) as entryAmount,
   
   (select sum(si.amount) from SaleItem si where si.productGrating.id = pg.id and si.sale.cancelledStatus = 0) as soldAmount,
   (select sum(stock.amount) from Stock stock where stock.productGrating.id = pg.id) as amount,
   (select stock.salePriceValue from Stock stock where stock.productGrating.id = pg.id and stock.establishment.id = 2) as salePrice,
   (select stock.promotionPrice from Stock stock where stock.productGrating.id = pg.id and stock.establishment.id = 2 ) as promotionPrice,
   (select stock.promotion from Stock stock where stock.productGrating.id = pg.id and stock.establishment.id = 2 ) as promotion,
   
   (select zmop.value from ZeroMarkOnPrice zmop where zmop.productGrating.id = pg.id and zmop.expenditure.establishment.id = 2 and zmop.cancelledStatus = 0
   and zmop.disactivated = 0 and zmop.id = (select 
                        max(zmopp.id)
                         from ZeroMarkOnPrice zmopp
                         where zmopp.productGrating.id = pg.id   
                         and zmopp.expenditure.establishment.id = 2
                        and zmopp.cancelledStatus = 0
                                     and zmopp.disactivated = 0)
   ) as zeroMarkOnPriceValue
   from
   ProductGrating pg,
   Supplier sup,
   SupplierReference sr,
   FiscalInvoiceItem fii
   
   where
   sr.productGrating.id = pg.id
   and sr.supplier.id = sup.id
      and fii.productGrating.id = pg.id
   
      and fii.cancelledStatus = 0
      and fii.fiscalInvoice.invoiceState = 2
      and fii.fiscalInvoice.cancelledStatus = 0
   
      and fii.fiscalInvoice.establishment.id = 2
      and pg.id > 21900 and pg.id < 220000
      
   group by
      pg.id
   order by
      pg.id


The weird thing is when i run this query at the Hibernate Tools on Eclipse 3.1.1 everything works fine, but when it runs on my java class..

Code:
// creating query
            Query query = session.createQuery(getHibernateQuery().getHql());
           
            // setting parameters
            getHibernateQuery().setParameters(query);
           
            // store the result
            List result = query.list();



i get this error

Code:
Caused by: java.lang.NullPointerException
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.aliasedSelectExpr(HqlSqlBaseWalker.java:1703)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.constructor(HqlSqlBaseWalker.java:1943)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectExpr(HqlSqlBaseWalker.java:1594)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectExprList(HqlSqlBaseWalker.java:1467)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectClause(HqlSqlBaseWalker.java:1041)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:380)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:201)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:151)
   at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189)
   at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130)
   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)


I'm using exactly the same hql query builded on the Hibernate Tools.
Does anybody knows what's wrong?

Thanks.


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.