-->
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.  [ 4 posts ] 
Author Message
 Post subject: maths operators
PostPosted: Mon Mar 19, 2007 7:38 am 
Regular
Regular

Joined: Thu May 11, 2006 12:30 pm
Posts: 72
I need to nest an aggregate query in another HQL query, so I write this :

Code:
IQuery queryCommesseODL = this.m_session.CreateQuery("select odl from OrdineDiLavoro as odl inner join odl.Commessa as com where odl.Stato <> 'C' and odl.Commessa.Stato <> 'C' and odl.MatricolaSviluppatore=:dev and ((odl.OreTotali+(odl.MinutiTotali/60)) > (select (sum(gnt.Ore)+(sum(gnt.Minuti)/60)) from Gantt as gnt where gnt.Matricola=odl.MatricolaSviluppatore and gnt.Cliente.Codice=odl.CodiceCliente and gnt.Anno=odl.Anno and gnt.Numero=odl.Numero))");


but I got exception, so I tried to simplify my query but I always got exception: finally I tried a super simple query and I'm getting strange work:

these queries works
Code:
select gnt.Ore , gnt.Minuti  from Gantt as gnt
select sum(gnt.Ore) , sum(gnt.Minuti)  from Gantt as gnt


these fails with following exception
Code:
select gnt.Ore + gnt.Minuti  from Gantt as gnt
select sum(gnt.Ore) + sum(gnt.Minuti)  from Gantt as gnt
select sum(gnt.Ore) , sum(gnt.Minuti)/60  from Gantt as gnt


Exception
Code:
NHibernate.QueryException: , expected in SELECT [select sum(gnt.Ore) , sum(gnt.Minuti)/60  from FinitenessEvo.Domain.Gantt as gnt]
   in NHibernate.Hql.Classic.SelectParser.Token(String token, QueryTranslator q)
   in NHibernate.Hql.Classic.ClauseParser.Token(String token, QueryTranslator q)
   in NHibernate.Hql.Classic.ClauseParser.End(QueryTranslator q)
   in NHibernate.Hql.Classic.PreprocessingParser.End(QueryTranslator q)
   in NHibernate.Hql.Classic.ParserHelper.Parse(IParser p, String text, String seperators, QueryTranslator q)
   in NHibernate.Hql.Classic.QueryTranslator.Compile()
   in NHibernate.Hql.Classic.QueryTranslator.Compile(IDictionary replacements, Boolean scalar)
   in NHibernate.Impl.SessionFactoryImpl.GetQuery(String queryString, Boolean shallow, IDictionary enabledFilters)   in Ayende.NHibernateQueryAnalyzer.Model.Project.HqlToSql(String hqlQuery, IDictionary parameters)
   in Ayende.NHibernateQueryAnalyzer.UserInterface.Presenters.QueryPresenter.TranslateHql()


Why ?

Hibernate version:
1.2.0. CR1
Mapping documents:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" >
  <class name="FinitenessEvo.Domain.Gantt, FinitenessEvo.Domain" table="tabgant" >
    <composite-id>
      <key-property name="IDMatricola" column="ganmat" />
      <key-property name="Anno" column="ganann"/>
      <key-property name="Numero" column="gannum"/>
      <key-property name="CodiceCliente" column="gancli" />
      <key-property name="Giorno" column="gangio" />
    </composite-id>
    <property name="Ore" column="ganore" />
    <property name="Minuti" column="ganmin" />
    <property name="FlagTipo" column="ganflg" />
    <property name="Stato" column="ganac" />
    <property name="OraInizio" column="gansth" />
    <property name="MinutiInizio" column="ganstm" />
    <property name="Note" column="gannot" />
  </class>
</hibernate-mapping>


Full stack trace of any exception that occurs:

Name and version of the database you are using:
MS SQL 2005


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 23, 2007 7:53 am 
Regular
Regular

Joined: Thu May 11, 2006 12:30 pm
Posts: 72
any idea ? I'm thinking is a bug...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 27, 2007 4:27 pm 
Beginner
Beginner

Joined: Mon Apr 24, 2006 1:43 pm
Posts: 22
No idea, unfortunately. But, I see the same exceptions when I try queries which include math operations between aggregate functions, like
Code:
select sum(x.property1)/sum(x.property2) from MyObj x


Yes, I think it's a bug.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 21, 2008 5:23 am 
Regular
Regular

Joined: Thu Mar 06, 2008 5:06 am
Posts: 68
Yes, math operators are not supported in NHibernate 1.2, but are they in NHibernate 2.0?


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