-->
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: How to get Hibernate to refresh by external db changes
PostPosted: Mon Nov 21, 2005 10:46 am 
Newbie

Joined: Wed May 04, 2005 3:33 am
Posts: 6
Hibernate version:2.1.7c

Name and version of the database you are using: MySQL 4.1

I have the following problem: I have 2 different Webapplications deployed on a Tomcat server which both write into the same DB.
When one application writes into the DB, the other sees the change about an hour later (or so .... but not immediatly). I also noted that the same thing occurs if I change data using the MySQL Control Center.

Is there a way to be sure that the data is retrieved from the db and not the cache?

Here is a sniplet of what I am doing

Code:
session = sessionFactory.openSession();
tx = session.beginTransaction();
Criteria crit = session.createCriteria( Duh.class );
crit.add( Expression.eq( Duh.PROP_Duh, "XXXX" );
crit.setLockMode(LockMode.READ);
li = crit.list();
tx.commit();
session.close();


Note that I used the LockMode.Read for the query. The Hibernate in Action document states :

Quote:
Bypass both levels of cache and perform a version check to verify that the object in memory is the same version that currently exists in the database
.

Am I doing something wrong (I don't have any versioning in my db objects so the lockmode might be false)?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 21, 2005 11:18 am 
Beginner
Beginner

Joined: Thu Aug 11, 2005 5:19 am
Posts: 29
Well, don't know if it will help, but:

I had this problem too on very early stage of my project.
Later I updated the whole stuff like described here:

http://hibernate.org/42.html

Then the problem is gone, the updates are visible with no latency.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 21, 2005 11:25 am 
Newbie

Joined: Wed May 04, 2005 3:33 am
Posts: 6
Thanks but the document is for the hibernate 3.1 version. Maybe i should add that we are using a JDBC Connection (JConnector) maybe that might be a problem.


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.