Hi,
I have activated the 2nd level cache in my domain with the following configuration:
Code:
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.0" >
<session-factory name="MyApp">
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string">connection string is here!</property>
<property name="show_sql">false</property>
<property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
<property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
<property name="hibernate.cache.provider_class">NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache</property>
<property name="relativeExpiration">300</property>
<property name="cache.use_query_cache">true</property>
<!-- Mapping files -->
<mapping assembly="MyDomain" />
</session-factory>
</hibernate-configuration>
I have also added <cache> elements to all of my domain objects and to the collections. Example mapping:
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" schema="dbo">
<class name="MyDomain.Parent, MyDomain" table="Parent">
<cache usage="read-write"/>
<id name="ID" type="Int32" column="ID">
<generator class="identity"/>
</id>
<set name="Children" table="Child" inverse="true" lazy="true" cascade="all-delete-orphan">
<cache usage="read-write"/>
<key column="ParentID"/>
<one-to-many class="MyDomain.Child, MyDomain"/>
</set>
...
</class>
</hibernate>
However, when I watch the DB activity in SQL Server profiler, I am still seeing hits on the DB to load the collections when I access the Parent.Children property.
Must be missing something real basic but I can't seem to find it.
Any ideas?
Thanks,
Jason