Hi all,
I have the following mapping:
<class name="com.pjuza.oncology.domain.Parameter" table="parameters">
<cache usage="nonstrict-read-write"/>
<id name="id" column="param_id">
<generator class="increment"/>
</id>
<discriminator column="type" type="string"/>
<property name="name" column="name" not-null="true" />
<subclass name="com.pjuza.oncology.domain.LocalizationParam" discriminator-value="1"/>
<subclass name="com.pjuza.oncology.domain.OrganParam" discriminator-value="2"/>
<subclass name="com.pjuza.oncology.domain.PictureObjectParam" discriminator-value="3"/>
<subclass name="com.pjuza.oncology.domain.TreatmentParam" discriminator-value="4"/>
<subclass name="com.pjuza.oncology.domain.PictureTypeParam" discriminator-value="5"/>
</class>.
Generally these parameters are changed very seldom and there are fetched very often. Thus I would like to optimalize fetching of them because now I see five SELECT queries everytime I need them.
I use this function for loading objects (from Spring):
public List loadAll(final Class entityClass) throws DataAccessException {
return (List) execute(new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException {
Criteria criteria = session.createCriteria(entityClass);
prepareCriteria(criteria);
return criteria.list();
}
}, true);
}
I use "standard" Hibernate installation without special configuration - I thought that Hibernate use cache by default... I'm not able to force Hibernate to cache it.
Thank you very much.
PETER
|