From: <leg...@at...> - 2003-08-27 20:10:28
|
The following comment has been added to this issue: Author: John Kristian Created: Wed, 27 Aug 2003 3:09 PM Body: Here's a log excerpt from a similar case, which I hope will help. 2003-08-27 12:21:35,312 DEBUG [net.sf.hibernate.impl.SessionImpl] refreshing [com.docent.lms.entities.reference.ReferenceLearningActivity#49] 2003-08-27 12:21:35,312 DEBUG [net.sf.hibernate.persister.EntityPersister] Materializing entity: com.docent.lms.entities.reference.ReferenceLearningActivity#49 ... 2003-08-27 12:21:35,312 DEBUG [net.sf.hibernate.loader.Loader] Initializing object from ResultSet: 49 2003-08-27 12:21:35,312 DEBUG [net.sf.hibernate.loader.Loader] Hydrating entity: com.docent.lms.entities.reference.ReferenceLearningActivity#49 ... 2003-08-27 12:21:35,312 DEBUG [net.sf.hibernate.loader.Loader] total objects hydrated: 1 2003-08-27 12:21:35,312 DEBUG [net.sf.hibernate.impl.SessionImpl] resolving associations for [com.docent.lms.entities.reference.ReferenceLearningActivity#49] ... 2003-08-27 12:21:35,312 DEBUG [net.sf.hibernate.impl.SessionImpl] adding entity to JCS cache [com.docent.lms.entities.reference.ReferenceLearningActivity#49] 2003-08-27 12:21:35,312 DEBUG [net.sf.hibernate.cache.ReadWriteCache] Caching: 49 2003-08-27 12:21:35,312 DEBUG [net.sf.hibernate.cache.ReadWriteCache] Could not cache net.sf.hibernate.impl.CacheEntry#49; CachedItem is fresh 2003-08-27 12:21:35,312 DEBUG [net.sf.hibernate.impl.SessionImpl] done materializing entity [com.docent.lms.entities.reference.ReferenceLearningActivity#49] To obtain this log, I modified src/net/sf/hibernate/cache/ReadWriteCache.java thus: @@ -66,7 +66,19 @@ return true; } else { - if ( log.isTraceEnabled() ) log.trace("Could not cache: " + key); + if (log.isTraceEnabled()) { + StringBuffer msg = new StringBuffer(); + msg.append("Could not cache: ").append(key); + if ( ! item.isUnlocked()) + msg.append("; CachedItem is locked"); + if (item.isFresh()) + msg.append("; CachedItem is fresh"); + if (item.getUnlockTimestamp() >= txTimestamp) + msg.append("; CachedItem.unlockTimestamp ").append(item.getUnlockTimestamp()) + .append(" >= ").append(txTimestamp) + ; + log.trace(msg.toString()); + } return false; } } --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-295 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-295 Summary: Session.refresh leaves old data in JCS cache Type: Bug Status: Unassigned Priority: Minor Project: Hibernate2 Components: core Versions: 2.0.2 Assignee: Reporter: John Kristian Created: Wed, 27 Aug 2003 3:01 PM Updated: Wed, 27 Aug 2003 3:01 PM Environment: Windows XP, Microsoft SQL Server, JBoss 3 Description: http://sourceforge.net/forum/message.php?msg_id=2078891 Session session = sessionFactory.openSession(); Foo foo = session.load(Foo.class, id); // (1) // Now execute SQL via JDBC (not Hibernate) that changes the data from which foo is mapped. // (2) workaround: sessionFactory.evict(Foo.class, id); session.refresh(foo); // foo is copied from the database session.close(); session = sf.openSession(); Foo foo2 = session.load(Foo.class, id); // At this point, foo2 contains different data than foo. // foo2 contains the old data that foo contained at (1) above. session.close(); foo2 should contain the new data, just like foo. Ideally, session.refresh() would copy the new data into the cache. At least, it should invalidate the old cached data. One can work around this problem, by calling sessionFactory.evict at (2) above. --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |