-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 を使用してバッチでロードします。また、各バッチ間のセッションをクリアする必要があります。および/またはステートレス セッションを使用します。および/またはクエリ自体を単純な DTO インスタンスに投影させます。NHibernate はメモリ消費を削減するために追跡しません。または、そのような一括読み込みに NHibernate を使用しないでください (NHibernate の主な使用例ではありません)。

于 2012-09-20T14:59:13.030 に答える