-->
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.  [ 11 posts ] 
Author Message
 Post subject: To get latest values from database
PostPosted: Wed May 09, 2007 9:01 am 
Newbie

Joined: Wed May 09, 2007 8:49 am
Posts: 9
Hi,

I have two applications. But both are using the same database.
when i update a table from application 1, i am not able to see the latest(updated one) from my application 2.

I have done commit() after every transaction and also i am doing flush().

Can someone help me how to get the latest values from database as soon if i access that table from my another application.

rgd,
kalai.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 09, 2007 9:49 am 
Senior
Senior

Joined: Sat Apr 21, 2007 11:01 pm
Posts: 144
Are you using Spring or any other AOP? If so then I find that if I wait untill I've gone ousdie of the scope of a Service method and then query for a table again in another method it will force Hibernate to do a commit. (Which would let you get the current data from you DB in your other app.)

_________________
Everytime you get an answer to your question without giving credit; god kills a kitten. :(


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 12:41 am 
Newbie

Joined: Wed May 09, 2007 8:49 am
Posts: 9
Thanks for ur reply.

I am using Struts and Hibernate for both of my applications.

In application 1 i am using session.saveOrUpdate(saveData) to save the values.

In application 2 i am using find() method to get the values. In find method i am creating a criteria and afetr that i am calling criteria.list() to get the values.

I hope now my proplem will be clear for u.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 2:32 am 
Beginner
Beginner

Joined: Mon Apr 23, 2007 8:30 am
Posts: 27
Location: India
This may sound silly, did you actually queried the database to check if your saved or updated data is getting reflected in your table?


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 3:23 am 
Newbie

Joined: Wed May 09, 2007 8:49 am
Posts: 9
ofcourse...

I have checked in my database.Whatever i updated or saved from my application 1 is there in that table.

But still i am not able to see the updated values from application 2 .


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 3:25 am 
Newbie

Joined: Wed May 09, 2007 8:49 am
Posts: 9
pls note this also..

If i restart my tomcat i am getting my latest values..But before that i am not able to get that..


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 3:54 am 
Beginner
Beginner

Joined: Mon Apr 23, 2007 8:30 am
Posts: 27
Location: India
Are you using any kind of cache, there may be a possibility that the second app is fetching data from the cache, which is why when you restart your server you get the updated values. I am still trying to figure out the exact cause :-)


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 4:01 am 
Newbie

Joined: Wed May 09, 2007 8:49 am
Posts: 9
No. i am not using any kind of cache.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 4:58 am 
Beginner
Beginner

Joined: Mon Nov 06, 2006 2:40 am
Posts: 29
Location: New Delhi, India
set you log level to see hibernate genrated logs, and check the place where new session is created and query is fired


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 8:15 am 
Newbie

Joined: Wed May 09, 2007 8:49 am
Posts: 9
hi all,

i solved the problem..there was a problem with handling the transaction.

thanks for all ur help..


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 9:13 am 
Senior
Senior

Joined: Sat Apr 21, 2007 11:01 pm
Posts: 144
Glad to hear you have your issue solved now.
Please give credit to the people that helped you. >_>

_________________
Everytime you get an answer to your question without giving credit; god kills a kitten. :(


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