-->
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: second level cache and database timestamps
PostPosted: Tue Nov 07, 2006 9:32 pm 
Newbie

Joined: Fri Oct 03, 2003 8:44 am
Posts: 11
Hibernate version: 3.2

Name and version of the database you are using: mysql 5.x


I've got the second level cache enabled, and when I update a row in the database, the "lastModifiedColumn" of that row is automatically updated (it's defined as a timestamp in mysql). However, Hibernate, b/c of the second level cache, doesn't seem to notice this. That is, the "lastModifiedDate" in my Java object still is not updated when I reload the object (and understandably so - Hibernate has no reason to believe something has been changed in the database without its knowledge).

Here's the pseudo code:

MyObject o = dao.load(id);
o.setFoo("newfoo");
System.out.println(o.getLastModifiedDate()); // --> ten days ago
dao.save(o);

MyObject o2 = dao.load(id);
System.out.println(o.getLastModifiedDate()); // --> still ten days ago

What's the best way to get around this? Every object I have mapped has the same behavior. I'd rather not have everything in the cache expire as soon as it's put in:).

Thanks!
Jon


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.