Caches with Hibernate

2006-02-16
2013-05-14
  • Radu Antohi
    Radu Antohi
    2006-02-16

    Hi,

    I'm having a problem regarding the caches with Hibernate. These caches are created automatically by EHCache.

    Using the config below, EHCache will create two caches:
    "com.dummy.Consultation.dom" and "com.dummy.ConsultationDom".

    Is this normal? Or maybe I didn't understand correctly how to use EHCache...

    I would like to have all the elements which have the same type in one single cache. Is it possible?

    I'm having something similar to the config below:

    <hibernate-mapping>
        <class name="com.dummy.Consultation" table="TB_Consultation" proxy="com.dummy.Consultation" >
               <cache usage="read-write" />
                   <id name="ik" column="ik" type="com.dummy.persistance.IKType" unsaved-value="null">
                       <generator class="com.dummy.persistance.IKTableHiLoGenerator"/>
                   </id>

                   <property name="info" type="com.dummy.persistance.InfoType">
                         <column name="noInfo1"/>
                         <column name="noInfo2" unique-key="ek"/>
            </property>
            <list table="TB_Dom" name="dom" cascade="all-delete-orphan" lazy="true">
                    <cache usage="read-write" />
                <key column="noConsultation"/>
                <one-to-many class="com.dummy.ConsultationDom"/>
            </list>
        </class>
    </hibernate-mapping>

    <hibernate-mapping>
                       <class name="com.dummy.ConsultationDom" table="TB_Dom" proxy="com.dummy.ConsultationDom" >
                              <cache usage="read-write" />
                              <id name="ik" column="ik" type="com.dummy.persistance.IKType" unsaved-value="null">
                                  <generator class="com.dummy.persistance.IKTableHiLoGenerator"/>
                              </id>

                              <many-to-one name="consultation" class="com.dummy.Consultation" outer-join="false">
                               <column name="noConsultation"/>
                      </many-to-one>
                              <many-to-one name="dom" class="com.dummy.Domaine" outer-join="false">
                               <column name="dom"/>
                      </many-to-one>
                   </class>
    </hibernate-mapping>

     

  • Anonymous
    2011-10-26

    Holds by  net.sf.ehcache.transaction.xa.XATransactionStore