-->
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.  [ 7 posts ] 
Author Message
 Post subject: session.find returning stale results
PostPosted: Wed Sep 01, 2004 3:01 pm 
Newbie

Joined: Wed Sep 01, 2004 2:56 pm
Posts: 3
Location: St. Louis
I am using Hibernate 2.1.4 and I am noticing a weird behavior from something that I believe I must have done wrong. As I understand session.find should return results directly from the DB and not from the cache. I am returning a list of results by the following:

Iterator iter = session.find("from com.scottrade.nagios.hibernate.Hoststatus host").iterator();

I am using that instead of session.iterate because I do not want to use the cache. The reason is that the database is being written to by another application and I want to read in the fresh data. In this case, that is not occurring.

Is there something that I am missing?

Thank you,

Andrew Janian
OMS Developer
Scottrade Financial Services
ajanian@scottrade.com


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 01, 2004 3:56 pm 
Regular
Regular

Joined: Mon Oct 06, 2003 7:17 am
Posts: 58
Location: Switzerland
Did you change the FlushMode to FlushMode.COMMIT? Because then it is possible that you receive stale data. In this case, a flush to the database is done when you commit the transaction and not before you call the find() method.

Reto


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 01, 2004 5:48 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
you may use session.clear() before calling find or use a new session

your session should have a short life.... if you are sometimes seeing stale data, it may be because you are considering the session as a global cache --> it isn't!

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 02, 2004 10:23 am 
Newbie

Joined: Wed Sep 01, 2004 2:56 pm
Posts: 3
Location: St. Louis
The other application is not using hibernate. That is the root of the problem. I am not able to use session.clear() because that makes the query take 8 seconds per use. This page is supposed to refresh every 10 seconds, so that would not make sense.

This is not really a great place to use hibernate, except for the OR mappings. I don't want the cache at all, but I seem to paying to much in time for the OR mappings.

As a last attempt, how do I set the cache expiration for an object?

Thanks for your help,

Andrew


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 02, 2004 12:20 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
Quote:
I am not able to use session.clear() because that makes the query take 8 seconds per use.


why?

when you do it in pure sql, how long does it take?

are you sure you need an orm?

are you sure tunning the query is not the real problem?

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 13, 2004 12:50 pm 
Newbie

Joined: Tue Aug 24, 2004 5:33 am
Posts: 8
Location: Russia
I have the same problem. When a database is accessed from another application we get stale data. To overcome this problem we need to refresh each list item. But why? The Session.find method already has read data by a query like "select * from ...". But only primary keys are controlled.


Top
 Profile  
 
 Post subject: I agree
PostPosted: Mon Sep 13, 2004 12:52 pm 
Newbie

Joined: Wed Sep 01, 2004 2:56 pm
Posts: 3
Location: St. Louis
I thought that was the precise difference between find and iterate. Are we misunderstanding something?


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