Note that there are some explanatory texts on larger screens.

plurals
  1. PONHibernate named query and 2nd level cache
    primarykey
    data
    text
    <p>I have the following mapping</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Domain.Core" namespace="Domain.Core"&gt; &lt;class name="Industry" table="INDUSTRY"&gt; &lt;cache usage="read-write" region="IndustryCache" include="all"/&gt; &lt;id name="Id" type="Int64" column="IID"&gt; &lt;generator class="sequence"&gt; &lt;param name="sequence"&gt;INDUSTRY_SEQ&lt;/param&gt; &lt;/generator&gt; &lt;/id&gt; &lt;version name="Version" column="VERSION" access="property" unsaved-value="null" generated="never"/&gt; &lt;property name="CreationTime" column="CREATE_DATE" type="DateTime" not-null="true" /&gt; &lt;property name="CreatedBy" column="CREATE_USER" type="String" not-null="true" /&gt; &lt;property name="LastUpdateTime" column="MODIFY_DATE" type="DateTime" not-null="false" /&gt; &lt;property name="LastUpdateBy" column="MODIFY_USER" type="String" not-null="false" /&gt; &lt;property name="Code" column="INDUSTRY" type="String" not-null="false" /&gt; &lt;map name="Resources" table="INDUSTRY_TL" fetch="subselect"&gt; &lt;cache region="IndustryCache" usage="read-write" include="all"/&gt; &lt;key column="INDUSTRY_ID"/&gt; &lt;composite-index class="Framework.Globalization.UILanguage, Framework"&gt; &lt;key-property name="Code" column="LANG" access="property" /&gt; &lt;/composite-index&gt; &lt;composite-element class="Industry+Translation"&gt; &lt;property name="Name" column="Industry_TL" /&gt; &lt;/composite-element&gt; &lt;/map&gt; &lt;/class&gt; &lt;query name="GetIndustyOrderByName"&gt; &lt;![CDATA[ from Industry as i left join fetch i.Resources as res where INDEX(res) = :lang order by res.Name ]]&gt; &lt;/query&gt; &lt;/hibernate-mapping&gt; </code></pre> <p>and the following configuration in hibernate.cfg.xml</p> <pre><code>&lt;property name="show_sql"&gt;true&lt;/property&gt; &lt;property name='proxyfactory.factory_class'&gt;NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle&lt;/property&gt; &lt;property name='prepare_sql'&gt;true&lt;/property&gt; &lt;property name='query.substitutions'&gt;Y=true,N=false,0=false,1=true&lt;/property&gt; &lt;property name="generate_statistics"&gt;true&lt;/property&gt; &lt;property name="cache.use_second_level_cache"&gt;true&lt;/property&gt; &lt;property name="cache.provider_class"&gt;Framework.Cache.SossCacheProvider, Framework.Cache.SossNHibernateCache&lt;/property&gt; &lt;property name="cache.use_query_cache"&gt;true&lt;/property&gt; </code></pre> <p>Now when I run the named query with SetCacheable(true) which calls out to the mapped collection, it doesn't get to the 2nd level cache. Is there any reason why?</p> <p>More Generically, is there a way to put the resultset of a named query into second level cache?</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload