nhibernate 5.13.12 createsqlquery exec mysql sql occur datetime error

12 views
Skip to first unread message

黄浩

unread,
Aug 4, 2022, 5:03:21 PMAug 4
to nhusers
for example:
execute the code :

session.CreateSQLQuery("select CONVERT('2022-07-01 11:11:11',datetime) cd ").List()

then will throw error:
could not execute query
[ select CONVERT('2022-07-01 11:11:11',datetime) cd ]
[SQL: select CONVERT('2022-07-01 11:11:11',datetime) cd]

   在 NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters, IResultTransformer forcedResultTransformer, QueryCacheResultBuilder queryCacheResultBuilder)
   在 NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)
   在 NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters)
   在 NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet`1 querySpaces)
   在 NHibernate.Loader.Custom.CustomLoader.List(ISessionImplementor session, QueryParameters queryParameters)
   在 NHibernate.Impl.SessionImpl.ListCustomQuery(ICustomQuery customQuery, QueryParameters queryParameters, IList results)
   在 NHibernate.Impl.AbstractSessionImpl.List(NativeSQLQuerySpecification spec, QueryParameters queryParameters, IList results)
   在 NHibernate.Impl.AbstractSessionImpl.List(NativeSQLQuerySpecification spec, QueryParameters queryParameters)
   在 NHibernate.Impl.SqlQueryImpl.List()

only datetime is error,other such as char is success

session.CreateSQLQuery("select CONVERT('2022-07-01 11:11:11',char) cd ").List()
Reply all
Reply to author
Forward
0 new messages