-->
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.  [ 1 post ] 
Author Message
 Post subject: Weird caching problem
PostPosted: Fri Dec 29, 2006 8:13 am 
Beginner
Beginner

Joined: Fri Oct 27, 2006 3:35 pm
Posts: 21
Hi Folks,

I'm experiencing a weird caching problem with Hibernate. I've got a fairly simple schema representing an online shop, with approximately 12 tables. After doing an update (via my hibernate code), the data gets persisted properly (I can look at the data in the DB using pgAdmin), however if I look at the data through my web browser and refresh the page a few times, I see either the old data or new data pretty much randomly. If I wait a few minutes, or restart Tomcat then I just see the new data.

I've had a look on this forum, and this appears to be the same problem -

http://forum.hibernate.org/viewtopic.ph ... ight=cache

I've disabled all caching as suggested, and this works, but it has a terrible impact on performance. I'd really like to get caching working consistently.

I've also looked at using Session.clear() and Session.refresh(Object o) in my persistence handler class, but they don't seem to have any effect. Perhaps I'm not using them correctly?

Would upgrading to Hibernate 3.2 make a difference?

Cheers,
Richard.

Hibernate version:

3.1.3

Code between sessionFactory.openSession() and session.close():

public Object persistTransaction(MergeAction action) throws Exception {
Transaction tx = null;
Session session = null;
Object mergedObject = null;
try {
session = HibernateUtil.currentSession(this.hibernateConfig);
tx = session.beginTransaction();
mergedObject = action.execute(session);
tx.commit();
session.flush();
} catch (Exception e) {
e.printStackTrace();
tx.rollback();
throw new Exception(e);
} finally {
session.close();
}
return mergedObject;
}

I have lots of implementations of MergeAction in my DAOs, but the code normally just calls session.merge(Object o) for the object I want to persist.

Name and version of the database you are using:

Postgres 8.1


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.