Hi,

I've searched this forum to include a caching for Hibernate transactions. But when implementing these myself it just doesn't seem to work.
In a test I make 10 times a call and in the logging I still see 10 select statements so this means the caching is not working, right ?

Here's the hbm configuration :

Code:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN" 
    "http&#58;//hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
    <class
        name="be.smalsmvm.genesis.bean.code.base.RootCode"
        table="CodeTable"
        dynamic-update="false"
        dynamic-insert="false"
        discriminator-value="none"
    >
        <cache usage="read-only" />

        <id
            name="codeId"
            column="codeId"
            type="java.lang.Long"
        >
            <generator class="native">
            </generator>
        </id>

        <discriminator
            column="typeCode"
            type="string"
        />

        <set
            name="childCodes"
            lazy="true"
            inverse="true"
            cascade="all-delete-orphan"
            sort="unsorted"
            order-by="codeValue"
        >
            <cache 
                usage="read-only" 
             />

              <key
                  column="parentCodeId"
              >
              </key>

              <one-to-many
                  class="be.smalsmvm.genesis.bean.code.base.RootCode"
              />
        </set>

        <many-to-one
            name="parentCode"
            class="be.smalsmvm.genesis.bean.code.base.RootCode"
            cascade="save-update"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="parentCodeId"
        />

        <property
            name="typeCode"
            type="java.lang.String"
            update="false"
            insert="false"
            access="property"
        >
            <column
                name="typeCode" 
                unique-key="reference_constraint"
                index="code_index"
            />
     
        <subclass
            name="be.smalsmvm.genesis.bean.code.CivilStateTypeCode"
            dynamic-update="false"
            dynamic-insert="false"
            discriminator-value="CS"
        >   
           

        </subclass>
        <subclass
            name="be.smalsmvm.genesis.bean.code.EvidenceTypeCode"
            dynamic-update="false"
            dynamic-insert="false"
            discriminator-value="EV"
        >
	
        </subclass>
    </class>
</hibernate-mapping>
There are many subclasses and therefore we use a discriminator.
Should the caching attribute be applied to these subclasses ?

Here's my spring SessionFactory config :

Code:
<!-- the SessionFactory -->
	<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
		<property name="dataSource">
			<ref bean="dataSource"/>
		</property>
		 <property name="lobHandler">
		 	<ref bean="oracleLobHandler"/>
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">$&#123;hibernate.dialect&#125;</prop>
				<prop key="show_sql">true</prop>
				<prop key="use_outer_join">false</prop>
				<prop key="hibernate.hibernate.cache.provider_class">net.sf.hibernate.cache.EhCacheProvider</prop>
				<prop key="hibernate.hibernate.cache.use_query_cache">true</prop>
			</props>
		</property>
		<property name="mappingJarLocations">
			<list>
				<value>file&#58;$&#123;genesis.datamodel.jar&#125;</value>
			</list>
		</property>
	</bean>
Anybody an idea why the caching is not working ?

Thanks for any advice...

Kristof