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: SQL Query result caching weirdness
PostPosted: Wed Mar 08, 2006 12:15 am 
Newbie

Joined: Wed Mar 08, 2006 12:03 am
Posts: 4
I have a weird caching problem that I cannot seem to resolve through my standard google-search means, read the faq, etc. I think my problem is a hibernate caching thing but I could be wrong.

I've got a chunk of code that runs and then sleeps for 30 seconds in a while ( FOREVER ) loop. Essentially it does this:

Code:
   org.hibernate.SQLQuery query = session.createSQLQuery( "select {u.*} from users u where u.firstname =  :first" );
   query.addEntity( "u", User.class );
   query.setString( "first", first );
   users = query.list();

   // now display all of the users


The first time thru this runs fine, displaying all users who have a first name specified by the variable: first. In my example, I am searching for all user's with a first name of "Joe". The above query grabs "Joe Smith" "Joe Rhodes" etc

Next, I update the list of users, adding "Joe Jones" via the mysql command line interface and commit the changes.

After the 30 second sleep() times out, the code runs again as before giving me the same results - "Joe Jones" is missing. Somehow Hibernate is caching the query results from the first pass. If I restart the application, it picks up the changes just fine.

I've looked for info about this but I can't find anything that suggests this should be happening. Can anyone point me in the right direction? For what it's worth, I'm using hibernate3. Thanks.

-j


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 08, 2006 12:24 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Likely a result of transaction isolation.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 08, 2006 12:50 am 
Newbie

Joined: Wed Mar 08, 2006 12:03 am
Posts: 4
gavin wrote:
Likely a result of transaction isolation.


So it does... I changed it to Read Committed Isolation and it seems to be working now. Many thanks!

-j


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.