Announcement Announcement Module
Collapse
No announcement yet.
How do I integrate Spring Hibernate and Ehcache Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do I integrate Spring Hibernate and Ehcache

    Hi

    All the example I have found regarding integration of Spring and Hibernate do not mention how to additionally integrate caching information when setting up secondary cache such as ehcache.


    So far I ahve this:

    <bean id="mySessionFactory" class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
    <property name="dataSource"><ref local="myDataSource"/></property>
    <property name="mappingResources">
    <list>
    <value>com/invest/model/AssetCatgry.hbm.xml</value>
    </list>
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">net.sf.hibernate.dialect.M ySQLDialect</prop>
    <prop key="hibernate.query.substitutions">true=1 false=0</prop>
    <prop key="hibernate.connection.driver_class">com.mysql. jdbc.Driver</prop>
    <prop key="hibernate.connection.username">root</prop>
    <prop key="hibernate.connection.password">tennis</prop>
    <prop key="hibernate.connection.url">jdbc:mysql://localhost:3306/invest</prop>
    <prop key="hibernate.hibernate.cache.provider_class">net .sf.hibernate.cache.EhCacheProvider</prop>
    <prop key="hibernate.hibernate.cache.use_query_cache">tr ue</prop>
    </bean>

    however I need to specify the following attribute to indicate to Hibernate that I am using a second level cache.

    <class-cache
    class="com.invest.model.AssetCatgry"
    usage="read-only"/>

    How do I do this in Spring?

    THanks
    Alex

  • #2
    Alex,

    EHCache based Hibernate caching is managed by Hibernate. You can, for instance, add this tag in the domain.hbm.xml files:
    Code:
      <class name="AssetCategry" table="Asset_Categry">
        <cache usage="read-only"/>
      ...
      </class>
    HTH

    Comment


    • #3
      How about the configuration in ehcache.xml ? Do I have to specify every cacheable object, in this case every persistent object ?

      Comment

      Working...
      X