-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: How to Implement second level caching!!!!
PostPosted: Mon Mar 15, 2010 6:40 am 
Newbie

Joined: Mon Mar 15, 2010 6:21 am
Posts: 2
Hi I am new to Hibernate.I have used Struts 2 and Hibernate 3.1.3 How can I Implement second level caching.
I tried in following way but I could not achieved. Please guide me to solve my problem.
Note :I did not mentioned anything about cache in my session factory class

hibernate.cfg
-------------
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>

ehcache.xml
------------
<diskStore path="c://cache"/>

<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="true"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
/>

<cache name="fi.qaim.opinionprofiler.model.SurveyVO"
maxElementsInMemory="300"
eternal="true"
overflowToDisk="true"
/>
</ehcache>
Survey.hbm.xml :
---------------
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

<class name="fi.qaim.opinionprofiler.model.SurveyVO"
table="survey">
<cache usage="read-write"/>
<id name="surveyId" column="survey_key">
<generator class="native" />
</id>
<property name="categoryId" column="category_key" />
<property name="customerId" column="customer_key" />
<property name="surveyName" column="name" />
<property name="surveyDescription" column="description" />
<property name="defaultLanguageKey" column="default_lang_key" />
<property name="redirectUrl" column="redirect_url" />
<property name="status" column="status" />
<property name="showDashboard" column="show_dashboard" />
<property name="startDate" column="start_date" />
<property name="endDate" column="end_date" />
<property name="created" column="created" />
<property name="updated" column="updated" />
<property name="responseGoal" column="response_goal" />
<property name="totalResponses" column="total_responses" />
<property name="surveyProgress" column="survey_progress" />
<many-to-one name="category" column="category_key" fetch="join"
class="fi.qaim.opinionprofiler.model.CategoryVO" insert="false" update="false" not-null="true" />
<many-to-one name="customerVo" column="customer_key" fetch="join"
class="fi.qaim.opinionprofiler.model.CustomerVO" insert="false" update="false" not-null="true" />
<many-to-one name="languageVo" column="default_lang_key" fetch="join"
class="fi.qaim.opinionprofiler.model.LanguageVO" insert="false" update="false" not-null="true" />
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject: Re: How to Implement second level caching!!!!
PostPosted: Mon Mar 15, 2010 6:57 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Quote:
tried in following way but I could not achieved. Please guide me to solve my problem.


What could not be achieved ?
Whats your problem?

Do you get exceptions?
Is the application performing selects which you don't excpect?


Top
 Profile  
 
 Post subject: Re: How to Implement second level caching!!!!
PostPosted: Mon Mar 15, 2010 7:10 am 
Newbie

Joined: Mon Mar 15, 2010 6:21 am
Posts: 2
I did not get any exception. With in the c://cache folder some DATA file are created but always that DATA file size is zero.


Top
 Profile  
 
 Post subject: Re: How to Implement second level caching!!!!
PostPosted: Mon Mar 15, 2010 8:27 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Consider that overflowToDisk="true" means that only after 'overflow' entities are written to disk.
With maxElementsInMemory set to "300" it means that you must load more than 300 distinct SurveyVO
instances in order that Ehcache begins to write to disk.
Did you load more than 300 SurveyVO objects?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.