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
|