I am currently using NHibernate to read a block of 50k rows. It takes almost 20 minutes.
Data which is to be read is prepared by joining more than 5 tables in SQLSERVER 2005.
My main concern is NHibernate prepares a new query for each row retrieval, which is quite time consuming.
I know it's necessary as NHibernate has to map each row to an object, but this approach is useless where reading is main concern.
I cannot use Stateless sesstion as I am using collections to store data
I also need to apply some filter through parameters. I have also implemented Stored Procedure, but somehow it didn't help.
Is there any other way to handle large collection of data.
------Edit-------
Here are my two config file which I was using to map
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="myNameSpace" assembly="myNameSpace">
<class name="MyClass" table="TableNameFromDb">
<id name="ID" column="ID">
<generator class="native" />
</id>
<property name="prop1"/>
<property name="prop2"/>
<bag name="bag1" cascade="all-delete-orphan" inverse="false" fetch="join" lazy="false">
<key column="prop1"/>
<one-to-many class="MyClass2" />
</bag>
</class>
</hibernate-mapping>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="myNameSpace" assembly="myNameSpace">
<class name="MyClass2" table="TableNameFromDb2">
<id name="prop2" column="ID">
<generator class="native" />
</id>
<property name="prop2"/>
<property name="prop3"/>
</class>
</hibernate-mapping>
Now the main concern here is NHibernate is creating a new query for each row and sending to the database which is an overhead.