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.