在使用无状态时,iquery枚举的notsupportedException
-
21-09-2019 - |
题
当尝试在指定查询上使用枚举方法,并带有无状态会话,如下所示:
http://www.nhforge.org/doc/nh/en/#batch-statatelessessession
我看到了一个notsupportedException。堆栈跟踪如下:
System.NotSupportedException: Specified method is not supported.
at NHibernate.Impl.StatelessSessionImpl.Enumerable(String query, QueryParameters parameters)
at NHibernate.Impl.QueryImpl.Enumerable()
这是我的代码的片段:
IStatelessSession statelessSession = sessionFactory.OpenStatelessSession();
var fileLines = statelessSession.GetNamedQuery("GetLinesByFileId")
.SetInt32("FileIdInput", fileId).Enumerable<FileLineEntity>();
命名的查询,getlinesbyfileid在HBM中定义如下:
<query name="GetLinesByFileId" cacheable="false" read-only="true">
<![CDATA[
from FileLineEntity lineItem where lineItem.FileId=:FileIdInput
]]>
</query>
关于我在这里可能缺少什么的建议吗?
解决方案
文档是错误的。另外,通过查看它,您可以从Hibernate(Java)复制它。
使用 List
方法。
不隶属于 StackOverflow