-1

加载具有许多记录(1000 万)的表的最佳方法是什么。

目前,我执行以下操作:

Session.QueryOver<Table>().List();

我得到以下异常:

     threw exception: 
NHibernate.Exceptions.GenericADOException: could not execute query
[ SELECT this_.Id as Id7_0_, this_.Tag as Tag7_0_, this_.Vss as Vss7_0_, this_.checkpoint_id as checkpoint4_7_0_, this_.vpg_id as vpg5_7_0_ FROM "CheckpointToProtectionGroup" this_ ]
[SQL: SELECT this_.Id as Id7_0_, this_.Tag as Tag7_0_, this_.Vss as Vss7_0_, this_.checkpoint_id as checkpoint4_7_0_, this_.vpg_id as vpg5_7_0_ FROM "CheckpointToProtectionGroup" this_] ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
4

1 回答 1

2

Skip/Take 或 SetFirstResult/SetMaxResults 批量加载。您还必须清除每个批次之间的会话。和/或使用无状态会话。和/或让查询本身投射到 NHibernate 不会跟踪的简单 DTO 实例以减少内存消耗。或者不使用 NHibernate 进行此类批量加载(它不是 NHibernate 的主要用例)。

于 2012-09-20T14:59:13.030 回答