Skip to content

Instantly share code, notes, and snippets.

@JeremySkinner
Created January 28, 2010 09:13
Show Gist options
  • Select an option

  • Save JeremySkinner/288570 to your computer and use it in GitHub Desktop.

Select an option

Save JeremySkinner/288570 to your computer and use it in GitHub Desktop.
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory name="MyApp">
<!-- ommitted connection configuration -->
<!-- Both cache and second level cache enabled -->
<property name="cache.provider_class">NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache</property>
<property name="cache.use_second_level_cache">true</property>
<property name="cache.use_query_cache">true</property>
<mapping assembly="MyApp.Model"/>
</session-factory>
</hibernate-configuration>
//Query is marked as cacheable, but the query cache is never used.
var rooms = session.CreateQuery("from Room order by Name")
.SetCacheable(true)
.List<Room>();
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="MyApp.Model" namespace="MyApp.Model">
<class name="Room" table="Rooms" mutable="false">
<!-- entity is set as cacheable -->
<cache usage="read-only" />
<id name="Id" column="Room_Id">
<generator class="identity"/>
</id>
<property name="Name" column="Room_Name"/>
<property name="UseForRegistration" column="Use_For_Registration" />
<property name="Bookable" />
<property name="NotAvailableToOthers" column="Not_Available_To_Others" />
</class>
</hibernate-mapping>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment