Announcement Announcement Module
Collapse
No announcement yet.
second level cache not working Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • second level cache not working

    I am trying to use second Level cache with EHCache. Below is my configuration.

    applicationContext.xml

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
    <property name="dataSource"><ref local="amsDataSource"/></property>
    <property name="mappingDirectoryLocations">
    <list>
    <value>classpath:/</value>
    </list>
    </property><!--
    <property name="mappingResources">
    <list>
    <value>a.hbm.xml</value>
    </list>
    </property>
    --><property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">org.hibernate.dialect.SQLS erverDialect</prop>
    <prop key="hibernate.show_sql">true</prop>
    <prop key="hibernate.c3p0.min_size">5</prop>
    <prop key="hibernate.c3p0.max_size">20</prop>
    <prop key="hibernate.c3p0.timeout">1800</prop>
    <prop key="hibernate.c3p0.max_statements">50</prop>
    <prop key="hibernate.cache.provider_class">org.hibernate .cache.EhCacheProvider</prop>
    <prop key="hibernate.cache.use_query_cache">true</prop>
    <prop key="hibernate.cache.use_second_level_cache">true</prop>
    <prop key="hibernate.cache.provider_configuration_file_r esource_path">ehcache.xml</prop>
    </props>
    </prope

    a.hbm.xml

    <hibernate-mapping>
    <class name="A" table="A">
    <cache usage="read-write"/>
    <id name="id" type="int" column="ID" >
    <generator class="increment"/>
    </id>
    <one-to-one name="b" class="B" cascade="all"/>
    </class>
    </hibernate-mapping>

    DAO


    HibernateTemplate ht = getHibernateTemplate();
    ht.loadAll(A.class);


    It generates Hibernate select statement every time I call ht.loadAll(A.class);. It should generate select statement only 1st time. Please let me know If i am doing anything wrong.

    Any help would be greatly appreciated.
    Last edited by mnrathod; Dec 29th, 2008, 06:40 AM. Reason: Wrong title
Working...
X