-->
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.  [ 3 posts ] 
Author Message
 Post subject: hibernate not getting the latest data from DB
PostPosted: Tue Jul 18, 2006 9:42 pm 
Newbie

Joined: Thu Jun 29, 2006 10:25 am
Posts: 4
Hi,

I have a problem in retrieving the latest data in the database using hibernate. In my application, I log in to an account and modify a record in the DB using session.update(instance) [with committed at the end]. I can see in the DB table that it was properly updated. However, when I try to view my update with the same user, the data retrieved not updated(even after removing the browser cache). I also tried logging in as a different user and data displayed is still the old one.

The right values will only be reflected after restarting the server. The problem might have something to do with my session/object mgt or I might have missed some configuration setting.

Im using the Hibernate util in

http://www.hibernate.org/hib_docs/refer ... start.html

and in my objetctDAO, I just have this to get the session.

private Session session = getSession();

protected Session getSession() {
try {
return HibernateUtil.currentSession();
} catch (Exception e) {
log.error("Could not locate SessionFactory in JNDI", e);
throw new IllegalStateException(
"Could not locate SessionFactory in JNDI");
}
}



Can anybody point me to the right direction? Ill appreciate any feedback/insight.

TIA


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 03, 2006 3:26 pm 
Newbie

Joined: Fri Feb 24, 2006 9:15 am
Posts: 17
Hello, did you find a solution for your problem? I'm having the same issue, and I've read some other threads with also the same problem, but nobody seems to answer them..


Top
 Profile  
 
 Post subject: hibernate not getting the latest data from DB (solved)
PostPosted: Tue Sep 05, 2006 8:58 am 
Newbie

Joined: Fri Feb 24, 2006 9:15 am
Posts: 17
Hello,

for the folks out there who are struggling with the same problem, I solved mine...

Quick answer: close the session after each operation. Probably you didn't, so when the object is being retrieved the second time, it's not obtained from the database, but from the session's first level cache. IF you close the session, next time a new session is created that accesses the database.
Here's an interesting thread I read on session and caching:
[url]http://forum.hibernate.org/viewtopic.php?t=961889&highlight=retrieved
[/url]
Although explained in many places in the documentation, it doesn't always seem the get through clearly..

Cheers, Bo


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