-->
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.  [ 5 posts ] 
Author Message
 Post subject: External database updates
PostPosted: Fri Sep 05, 2008 8:29 pm 
Newbie

Joined: Fri Sep 05, 2008 7:55 pm
Posts: 5
I have an application that is using Hibernate. It appears that I have to close the SessionFactory, then re-establish the SessionFactory and a new session to see updates done to the database by another application.

I this correct? I have this feeling that I am not doing something correct. Can anyone shed some light on this for me?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 09, 2008 4:53 pm 
Newbie

Joined: Fri Sep 05, 2008 7:55 pm
Posts: 5
doh!

Must have a transaction around a read only query.
Must have a transaction around a read only query.
Must have a transaction around a read only query.
Must have a transaction around a read only query.
Must have a transaction around a read only query.
Must have a transaction around a read only query.
Must have a transaction around a read only query.
Must have a transaction around a read only query.

:)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 09, 2008 8:30 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
You only want one SessionFactory, but you'll be creating many Session objects.

The Hibernate Session will cache changes and the entities you are using. If someone else updates the database underneath an active Session that is caching data, the Hibernate Session will get out of sync.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 09, 2008 9:45 pm 
Regular
Regular

Joined: Wed Apr 25, 2007 11:44 pm
Posts: 59
try to flush your data

and verify your results either querying from the same session or directly from the database


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 10, 2008 8:07 pm 
Newbie

Joined: Fri Sep 05, 2008 7:55 pm
Posts: 5
Thanks for the replies, but as I implied in my second post, I forgot to have my query in a transaction. Committing the transaction must do some cache updates or something that allow the query to be up to date.


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