Results 1 to 3 of 3

Thread: How do I integrate Spring Hibernate and Ehcache

  1. #1
    Join Date
    Jan 2005
    Posts
    5

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    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
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  3. #3
    Join Date
    Jul 2005
    Posts
    6

    Default

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

Similar Threads

  1. Replies: 7
    Last Post: Sep 15th, 2010, 07:25 AM
  2. Replies: 1
    Last Post: Oct 23rd, 2005, 02:43 PM
  3. EHCache + Hibernate + Spring
    By BenPoweski in forum Data
    Replies: 1
    Last Post: Oct 5th, 2005, 05:18 AM
  4. Spring - Hibernate - EHCache - Web App
    By macalla in forum Data
    Replies: 3
    Last Post: Jun 15th, 2005, 04:46 AM
  5. Hibernate 2.1.8 and ehcache provider issue and fix
    By Colin Sampaleanu in forum Data
    Replies: 0
    Last Post: Jan 31st, 2005, 09:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •