-->
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: Stored functions call bug
PostPosted: Tue Oct 11, 2005 8:36 am 
I need to call custom stored database function in HQL query. I have implemented my own descendant of NHibernate.Dialect.Oracle9Dialect to add my function name and datatype to a known functions list. If my function have 1 parameter, it works correctly. If I pass more than 1 parameter, for example
Code:
date_truncate(t3.BankDate,'day',1)
I have an exception
Quote:
Unhandled Exception: NHibernate.QueryException: alias or expression expected in SELECT [select new AccountOperationInfo(t1.Account.Id, sum(t3.Amount), count(t3.Id), date_truncate(t3.BankDate,'day',1) as dtr, t2.Account.Id) from Monitor.DomainModel.Repository.Operation t3 join t3.Contragents t1 join t3.Contragents t2 where t1.Account.Id in (14) and t1.Account != t2.Account and t3.BankDate >= '07.10.2005 00:00:00' and t3.BankDate <= '07.10.2005 00:00:00' group by t1.Account, t2.Account, date_truncate(t3.BankDate,'day',1)]
at NHibernate.Hql.SelectParser.Token(String token, QueryTranslator q)
at NHibernate.Hql.ClauseParser.Token(String token, QueryTranslator q)
at NHibernate.Hql.ClauseParser.End(QueryTranslator q)
at NHibernate.Hql.PreprocessingParser.End(QueryTranslator q)
at NHibernate.Hql.ParserHelper.Parse(IParser p, String text, String seperators, QueryTranslator q)
at NHibernate.Hql.QueryTranslator.Compile(String queryString)
at NHibernate.Hql.QueryTranslator.Compile(ISessionFactoryImplementor factory, String queryString, IDictionary replacements, Boolean scalar)
at NHibernate.Impl.SessionFactoryImpl.GetQuery(String query, Boolean shallow)
at NHibernate.Impl.SessionFactoryImpl.GetQuery(String query)
at NHibernate.Impl.SessionImpl.GetQueries(String query, Boolean scalar)
at NHibernate.Impl.SessionImpl.Find(String query, QueryParameters parameters)
at NHibernate.Impl.QueryImpl.List()


I looked at source code and it seems that a query parser recognize a comma between the parameters incorrectly.


Top
  
 
 Post subject:
PostPosted: Tue Oct 11, 2005 9:57 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
AFAIK, NHibernate doesn't support functions with more than one parameter.
Read: 11.5. Aggregate functions

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 11, 2005 11:11 am 
KPixel wrote:


It's not an agregate function, it's ordinary oracle stored function with DateTime returning value.


Top
  
 
 Post subject:
PostPosted: Wed Oct 12, 2005 1:42 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
OK; AFAIK, NHibernate doesn't support ordinary stored functions taking more than one parameter.

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


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.