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