NH version ? 2009/9/30 Kent Boogaart <[email protected]>
> > Hi all, > > The following HQL works: > > select Something, cast(((Something + 50) / 20) as int) from > Somewhere > > The following does not: > > select Something, cast(((Something + 50) / :divisor) as int) from > Somewhere > > The only difference is that I attempt to swap in a parameter rather > than hard-coding the divisor. I get the following exception when > attempting to create the query with a parameter and cast combination: > > NHibernate.QueryException: invalid Hibernate type for cast(): type ? > int not found [select Something, cast(((Something + 50) / :divisor) as > int) from Somewhere] > at NHibernate.Dialect.Function.CastFunction.Render(IList args, > ISessionFactoryImplementor factory) > at NHibernate.Hql.Ast.ANTLR.SqlGenerator.EndFunctionTemplate > (IASTNode m) > at NHibernate.Hql.Ast.ANTLR.SqlGenerator.methodCall() > at NHibernate.Hql.Ast.ANTLR.SqlGenerator.selectExpr() > at NHibernate.Hql.Ast.ANTLR.SqlGenerator.selectColumn() > at NHibernate.Hql.Ast.ANTLR.SqlGenerator.selectClause() > at NHibernate.Hql.Ast.ANTLR.SqlGenerator.selectStatement() > at NHibernate.Hql.Ast.ANTLR.SqlGenerator.statement() > at NHibernate.Hql.Ast.ANTLR.HqlSqlGenerator.Generate() > at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.DoCompile > (IDictionary`2 replacements, Boolean shallow, String collectionRole) > at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.Compile > (IDictionary`2 replacements, Boolean shallow) > at NHibernate.Engine.Query.HQLQueryPlan..ctor(String hql, String > collectionRole, Boolean shallow, IDictionary`2 enabledFilters, > ISessionFactoryImplementor factory) > at NHibernate.Engine.Query.HQLQueryPlan..ctor(String hql, Boolean > shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor > factory) > at NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(String > queryString, Boolean shallow, IDictionary`2 enabledFilters) > at NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(String > query, Boolean shallow) > at NHibernate.Impl.AbstractSessionImpl.CreateQuery(String > queryString) > > Can anyone suggest how I can get this to work, preferably with a > parameter? Worst-case is that I have to forgo the parameter and > dynamically construct the HQL, which obviously inhibits the ability of > the DB to cache an execution plan for my query. > > Thanks, > Kent > > > -- Fabio Maulo --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
