We use a collection of images stored on the database on the one of the objects in the application. The main object (appraisal) is "alive" during all the application, when the user navigates to the form where the images are shown we initialize the images collections before doing any data binding. We would like to be able to dehydrate this collections when the user navigates away as this is a pretty heavy collection and the performance downgrade is noticeable.
I'm fairly new to NHibernate and any help/comment is more than welcome.
Hibernate version: 2.2
Mapping documents:
<class name="DomainModel.Appraisal, DomainModel" table="Appraisal">
<id name="Id" column="Id" type="Int32" access="nosetter.camelcase-underscore" unsaved-value="-1">
<generator class="identity"/>
</id>
...
<set name="Images" table="Image" lazy="true" access="nosetter.camelcase-underscore" inverse="true" cascade="all-delete-orphan" order-by="PrintOrder">
<key column="Id"/>
<one-to-many class="DomainModel.Image, Chubb.Appraisal.DomainModel" />
</set>
Code between sessionFactory.openSession() and session.close():
NHibernateUtil.Initialize(appraisal);
NHibernateUtil.Initialize(appraisal.Images);
Full stack trace of any exception that occurs:
Name and version of the database you are using:
SQL Server 2005 9.0.3224
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
No
Read this:
http://hibernate.org/42.html