I am using Spring to create the SessionFactory:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
p:dataSource-ref="dataSource">
<property name="mappingResources">
<list>
<value>META-INF/mapping/domain-objects.xml</value>
</list>
</property>
<property name="hibernateProperties">
<value>
hibernate.show_sql=true
hibernate.format_sql=true
</value>
</property>
</bean>
I'd like to map one of the classes as read-only.
<class name="MyDomainObject">
<!-- everything works without this line -->
<cache usage="read-only" />
<id name="id" />
<property name="name"
column="name" />
</class>
After I added the caching strategy read-only to the mapping of MyDomainObject, the test program starts to throw exception:
Caused by: org.hibernate.cache.NoCachingEnabledException: Second-level cache is not enabled for usage [hibernate.cache.use_second_level_cache | hibernate.cache.use_query_cache]
I tried setting hibernate.cache.use_second_level_cache and/or hibernate.cache.use_query_cache to true.
<property name="hibernateProperties">
<value>
hibernate.show_sql=true
hibernate.format_sql=true
hibernate.cache.use_second_level_cache=true
hibernate.cache.use_query_cache=true
</value>
</property>
None of the options worked. What else do I need to use the read-only caching strategy?