Hi

I have a problem with HQL, the date function is not working, it is
throwing the exception below:
I'm using a simple query to get only the date from the DateTime field:
select date(t.Data) from Trajtimi t where t.Pacienti.ID = 3

I'm using "NHibernate.Dialect.MsSql2000Dialect" I've tried with
MsSql2008Dialect and also MsSql2005Dialect it's the same.

I've looked also at source of "NHibernate.Dialect.MsSql2000Dialect"
https://nhcontrib.svn.sourceforge.net/svnroot/nhibernate/trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs

I saw there the line,
RegisterFunction("date", new SQLFunctionTemplate(NHibernateUtil.Date,
"dateadd(dd, 0, datediff(dd, 0, ?1))"));

I think the date function is implemented I tried the funcion in sql
management studio
"dateadd(dd, 0, datediff(dd, 0, someDateTime))" and it is striping the
time very well, but Nhibernate its not, at least for me.

I don't know where I'm wrong, if you could guide me...

P.S. The same thing in SQLite is working perfect.

Visar


NHibernate.QueryException was unhandled
  Message="No data type for node: MethodNode ( ( date ( exprList
( trajtimi0_.Data trajtimi0_.ID Data ) ) ) [select date(t.Data) as
dteRegj from Entities.Trajtimi t where t.Pacienti.ID = 3]"
  Source="NHibernate"
  QueryString="select date(t.Data) from Entities.Trajtimi t where
t.Pacienti.ID = 3"
  StackTrace:
       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)

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to nhus...@googlegroups.com.
To unsubscribe from this group, send email to 
nhusers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to