From: Assaf B. (JIRA) <no...@at...> - 2006-06-06 02:09:19
|
2nd level cached collections are locked causing a cache miss ------------------------------------------------------------ Key: HHH-1813 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1813 Project: Hibernate3 Type: Bug Versions: 3.1 Environment: Hibernate 3.1, Oracle 10g, Linux Reporter: Assaf Berg Priority: Critical Attachments: testcase.tar.gz Using the second level cache, collections are fetched from the database due to the cached item being locked. This happens in the most simple use case: 1. Insert an entity with a collection 2. Commit. 3. Fetch the entity I've written a simple test case and see the following in the log file: 11:52:47,159 DEBUG [ReadWriteCache] Invalidating: domain.Cat.kittens#539957 11:52:47,177 DEBUG [ReadWriteCache] Inserting: domain.Cat#539957 11:52:47,179 DEBUG [ReadWriteCache] Inserted: domain.Cat#539957 11:52:47,180 DEBUG [ReadWriteCache] Inserting: domain.Kitten#540214 11:52:47,180 DEBUG [ReadWriteCache] Inserted: domain.Kitten#540214 11:52:47,181 DEBUG [ReadWriteCache] Releasing: domain.Cat.kittens#539957 11:52:49,221 DEBUG [ReadWriteCache] Caching: domain.Cat#539957 11:52:49,221 DEBUG [ReadWriteCache] Item was already cached: domain.Cat#539957 11:52:49,223 DEBUG [ReadWriteCache] Cache lookup: domain.Cat.kittens#539957 11:52:49,223 DEBUG [ReadWriteCache] Cached item was locked: domain.Cat.kittens#539957 11:52:49,229 DEBUG [ReadWriteCache] Caching: domain.Kitten#540214 11:52:49,229 DEBUG [ReadWriteCache] Item was already cached: domain.Kitten#540214 11:52:49,230 DEBUG [ReadWriteCache] Caching: domain.Cat.kittens#539957 11:52:49,231 DEBUG [ReadWriteCache] Cached: domain.Cat.kittens#539957 domain.Cat.kittens [C/H/M/P]: 1/0/1/1 domain.Cat [C/H/M/P]: 1/0/0/1 domain.Kitten [C/H/M/P]: 1/0/0/1 This happens whether the collection is mapped as inverse or not. I've attached the test case source and hbms (although it might need to be tweaked for the proper DB before running, and I didn't include the dependencies JARs). Here's a code excerpt of the interesting part (tx is TransactionTemplate using HibnerateTransactionManager and hibernate is HibernateTemplate from the spring framework): tx.execute(new TransactionCallback() { public Object doInTransaction(TransactionStatus status) { // create a Cat with one Kitten Cat cat = new Cat(); Kitten kitten = new Kitten(); cat.addKitten(kitten); hibernate.save(cat); return null; } }); Thread.sleep(2000L); tx.execute(new TransactionCallback() { public Object doInTransaction(TransactionStatus status) { // load all cats List<Cat> allCats = hibernate.loadAll(Cat.class); return null; } }); I can supply further information if needed. -- 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 - For more information on JIRA, see: http://www.atlassian.com/software/jira |