-->
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.  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Refreshing cache after db changes not done by hibernate
PostPosted: Wed Dec 17, 2008 3:09 am 
Newbie

Joined: Wed Dec 17, 2008 3:03 am
Posts: 9
Records of one of my database server is being modified by two way:

1) using an application where hibernate is used
2) using another server which also changes the same database using somehow.

My problem is that: changes done by another server is not reflects instantly in my application. My hibernate cache is not refreshed instantly.

What is the solution for this?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 17, 2008 6:14 am 
Regular
Regular

Joined: Wed Oct 15, 2008 6:59 am
Posts: 103
Location: Chennai
Use evict() method for ur sessionFactory.

_________________
If u feel it will help you, don't forget to rate me....


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 18, 2008 1:59 am 
Newbie

Joined: Wed Dec 17, 2008 3:03 am
Posts: 9
.....


Last edited by pramodkrjsr on Thu Dec 18, 2008 2:00 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 18, 2008 2:00 am 
Newbie

Joined: Wed Dec 17, 2008 3:03 am
Posts: 9
Madan_Prabhu wrote:
Use evict() method for ur sessionFactory.


That is fine. But how my application will know that the there is some db changes done. Because db changes was done from external system.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 18, 2008 2:01 am 
Newbie

Joined: Wed Dec 17, 2008 3:03 am
Posts: 9
Madan_Prabhu wrote:
Use evict() method for ur sessionFactory.


That is fine. But how my application will know that the there is some db changes done. Because db changes was done from external system.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 18, 2008 8:58 am 
Regular
Regular

Joined: Wed Oct 15, 2008 6:59 am
Posts: 103
Location: Chennai
User timer task to invoke evict() at specific intervals.

Normally hibernate makes itself synchronize with DB server.

Only method to synchronize with ur DB without restarting web server is using evict() methods on ur sessionFactory in specific intervals.

_________________
If u feel it will help you, don't forget to rate me....


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 19, 2008 5:25 am 
Newbie

Joined: Wed Dec 17, 2008 3:03 am
Posts: 9
We have already used a timeInterval of 30 min after which the cached is refreshed.

We cannot decrease this interval. I want that when the data changed externally, the cache should be refreshed instantly.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 19, 2008 9:23 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Quote:
I want that when the data changed externally, the cache should be refreshed instantly.


Then you need to arrange some way for the external application to notify your Hibernate application that the database has changed so that it can call SessionFactory.evict(). There is no way Hibernate can know when an update happens unless the external system somehow sends a note. Is it possible for you to use a clustered cache (for example the JBoss cache) and have the external system also use this cache? Or at least notify it that data has changed?

Decreasing the cache timeout is not a useful option since it will clear the cache even if the data hasn't change.


Top
 Profile  
 
 Post subject: See the image
PostPosted: Wed Dec 24, 2008 5:36 am 
Newbie

Joined: Wed Dec 17, 2008 3:03 am
Posts: 9
See the situation below:
I have no way to inform the hibernate of second system about the db change done.

Image


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 27, 2008 4:15 am 
Regular
Regular

Joined: Wed Oct 15, 2008 6:59 am
Posts: 103
Location: Chennai
just write a thread for calling evict() method in interval , becaz it doesn't take more time to execute.

_________________
If u feel it will help you, don't forget to rate me....


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 27, 2008 4:22 am 
Regular
Regular

Joined: Wed Oct 15, 2008 6:59 am
Posts: 103
Location: Chennai
u can do this by using JMS...

write the messaging system to alert the DB changes to ur other end, if the DB chage msg comes call evict() methods.

i think u will use openJMS for this purpose, becaz it'e very easy.

http://openjms.sourceforge.net/

_________________
If u feel it will help you, don't forget to rate me....


Top
 Profile  
 
 Post subject: Regarding jms
PostPosted: Tue Dec 30, 2008 2:55 am 
Newbie

Joined: Wed Dec 17, 2008 3:03 am
Posts: 9
Thanks for your idea of Messaging.

I have below issues:
1) Both the side we need the J2EE env.
2) Data are transfered mannualy.
3) Also, both the system are geographically at different locations, so jms will send a asynchronous messages which is not sure that when it will be read by other system.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 30, 2008 9:03 am 
Regular
Regular

Joined: Wed Oct 15, 2008 6:59 am
Posts: 103
Location: Chennai
OpenJMS doesn't need any J2ee stack, it's available as standalone.

u use persistent to send msg without any interruption. if u use that msg it will surely send to the system.

_________________
If u feel it will help you, don't forget to rate me....


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 31, 2008 5:09 am 
Newbie

Joined: Wed Dec 17, 2008 3:03 am
Posts: 9
Issue unresoved:

Data are transfered mannualy.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 31, 2008 4:58 pm 
Regular
Regular

Joined: Tue Dec 30, 2008 8:14 pm
Posts: 50
Oracle AQ can trigger a JMS message. If you are using PL/SQL to transfer data from ORA-1 to ORA-2, the same function may trigger a message to System-2. On receiving the message, System-2 may evict necessary objects.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 17 posts ]  Go to page 1, 2  Next

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.