使用无状态会话时 IQuery 的 Enumerable 上出现 NotSupportedException
当尝试在无状态会话的命名查询上使用 Enumerable 方法时,如以下示例所示:
http://www.nhforge.org/doc/nh/en/#batch-statelesssession
我看到一个 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>
关于我在这里可能缺少的内容有什么建议吗?
when trying to use the Enumerable method on a named query, with a Stateless session, as shown in the example at:
http://www.nhforge.org/doc/nh/en/#batch-statelesssession
i am seeing a NotSupportedException. the stack trace is as below:
System.NotSupportedException: Specified method is not supported.
at NHibernate.Impl.StatelessSessionImpl.Enumerable(String query, QueryParameters parameters)
at NHibernate.Impl.QueryImpl.Enumerable()
here is a snippet of my code:
IStatelessSession statelessSession = sessionFactory.OpenStatelessSession();
var fileLines = statelessSession.GetNamedQuery("GetLinesByFileId")
.SetInt32("FileIdInput", fileId).Enumerable<FileLineEntity>();
the named query, GetLinesByFileId is defined in the hbm as below:
<query name="GetLinesByFileId" cacheable="false" read-only="true">
<![CDATA[
from FileLineEntity lineItem where lineItem.FileId=:FileIdInput
]]>
</query>
any suggestions on what i maybe missing here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
医生错了。另外,通过查看它,您可以看出它是从 Hibernate (Java) 复制的。
请改用
List
方法。The doc is wrong. Also, by looking at it you can tell it's copied from Hibernate (Java).
Use the
List
method instead.