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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate caching issue
PostPosted: Fri Nov 03, 2006 5:21 am 
Beginner
Beginner

Joined: Thu Jul 13, 2006 10:39 am
Posts: 23
Hi all,

I am using EHCache provider for hibernate caching.

My code is working very fine with cache.

Cache used for my application is read-write.


I am using load() statements to retrieve the data from oracle database.

But the problem is when i am trying to retrieve the data for second time, I am not able to get latest updated data from database. I am using session pool mechanism.Session can't retrive latest submission object from database for an application.

Could anyone please h\give me the soultion for this?

My sample class:

<class name="Application" table="APPLICATION" dynamic-
update="true">
<cache usage="read-write"/>
<id name="applicationID" type="string" unsaved-
value="null">
<column name="APPLICATION_ID" sql-type="varchar2
(32)" />
</id>


<property name="agencyNumber">
<column name="AGENCY_NUMBER" sql-type="varchar2
(64)" />
</property>

<property name="applicationTypeID">
<column name="TYPE_ID" sql-type="varchar2(32)" />
</property>


<set name="submissions" table="Submission" inverse="false"
cascade="all" lazy="false">
<cache usage="read-write"/>
<key column="APPLICATION_ID" />
<one-to-many class="com.dfi.eCTD.Submission" />
</set>

</class>

sample code for retrieving application:

Sesion session=SessionManager.currentSession();
Application oApp=session.load(Application.class,applicationId);
session.clear();



Thanks and regards,
Sreekanth


Top
 Profile  
 
 Post subject: Re: Hibernate caching issue
PostPosted: Sat Nov 04, 2006 4:12 am 
Beginner
Beginner

Joined: Sat Sep 09, 2006 5:55 am
Posts: 23
Sreekanth wrote:
I am using EHCache provider for hibernate caching.
My code is working very fine with cache.
Cache used for my application is read-write.

I am using load() statements to retrieve the data from oracle database.

But the problem is when i am trying to retrieve the data for second time, I am not able to get latest updated data from database.


I think that when you use the second-level cache, it only knows about changes your application makes to the data, so if another application (or another instance of your application) updates the data, you will not see the changes. You can make the cache expire after a certain amount of time though.

From the Docs:
Code:
Be careful. Caches are never aware of changes made to the persistent store by another application (though they may be configured to regularly expire cached data)

_________________
Cheers,

Guy Mahieu


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.