Using V2.1.2.4000 of NHibernate, the following query fails:
select
charindex('f', 'abcdef', 3)
from
Whatever
Regardless of what entity entity is being selected, I get:
NHibernate.QueryException: No data type for node: MethodNode
( ( charindex ( exprList 'f' 'abcdef' 3 ) ) [select
charindex('f', 'abcdef', 3)
from
Entities.Whatever]
at
NHibernate.Hql.Ast.ANTLR.Tree.SelectClause.InitializeExplicitSelectClause
(FromClause fromClause)
at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.UseSelectClause(IASTNode
select)
at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.ProcessQuery(IASTNode
select, IASTNode query)
at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.unionedQuery()
at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.query()
at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.selectStatement()
at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.statement()
at NHibernate.Hql.Ast.ANTLR.HqlSqlTranslator.Translate()
at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.Analyze
(HqlParseEngine parser, String collectionRole)
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)
If I attempt to explicitly state the type as follows:
select
cast(charindex('f', 'abcdef', 3) as integer)
from
Whatever
I get:
NHibernate.QueryException: cast() requires two arguments [select
cast(charindex('f', 'abcdef', 3) as integer)
from
Entities.Whatever]
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)
I guess this is just because charindex isn't supported, since the same
thing happens when I attempt to pass call "charindexxxxx", which
obviously doesn't exist. So is there a charindex equivalent in HQL?
--
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.