HHH-9203 - ConcurrentNaturalIdCacheStatisticsImpl#getEntries() fails
with ClassCastException Conflicts: hibernate-core/src/test/java/org/hibernate/test/naturalid/mutable/cached/CachedMutableNaturalIdStrictReadWriteTest.java
This commit is contained in:
parent
e226cb9c7d
commit
73f7b18523
|
@ -31,7 +31,7 @@ import java.util.concurrent.locks.Lock;
|
|||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
import org.hibernate.cache.spi.CacheKey;
|
||||
import org.hibernate.cache.spi.NaturalIdCacheKey;
|
||||
import org.hibernate.cache.spi.Region;
|
||||
import org.hibernate.stat.NaturalIdCacheStatistics;
|
||||
|
||||
|
@ -145,7 +145,7 @@ public class ConcurrentNaturalIdCacheStatisticsImpl extends CategorizedStatistic
|
|||
final Iterator iter = this.region.toMap().entrySet().iterator();
|
||||
while ( iter.hasNext() ) {
|
||||
final Map.Entry me = (Map.Entry) iter.next();
|
||||
map.put( ( (CacheKey) me.getKey() ).getKey(), me.getValue() );
|
||||
map.put( ( (NaturalIdCacheKey) me.getKey() ).getNaturalIdValues(), me.getValue() );
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
package org.hibernate.test.naturalid.mutable.cached;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.stat.NaturalIdCacheStatistics;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.cache.CachingRegionFactory;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.stat.NaturalIdCacheStatistics;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.cache.CachingRegionFactory;
|
||||
import org.junit.Test;
|
||||
|
||||
public class CachedMutableNaturalIdStrictReadWriteTest extends
|
||||
CachedMutableNaturalIdTest {
|
||||
|
||||
|
@ -22,6 +23,30 @@ public class CachedMutableNaturalIdStrictReadWriteTest extends
|
|||
cfg.setProperty( CachingRegionFactory.DEFAULT_ACCESSTYPE, "read-write" );
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-9203" )
|
||||
public void testToMapConversion() {
|
||||
sessionFactory().getStatistics().clear();
|
||||
|
||||
final Session session = openSession();
|
||||
session.getTransaction().begin();
|
||||
final AllCached it = new AllCached( "IT" );
|
||||
session.save( it );
|
||||
session.getTransaction().commit();
|
||||
session.close();
|
||||
|
||||
final NaturalIdCacheStatistics stats = sessionFactory().getStatistics().getNaturalIdCacheStatistics(
|
||||
"hibernate.test." + AllCached.class.getName() + "##NaturalId"
|
||||
);
|
||||
|
||||
final Map entries = stats.getEntries();
|
||||
assertEquals( 1, entries.size() );
|
||||
final Serializable[] cacheKey = (Serializable[]) entries.keySet().iterator().next();
|
||||
assertEquals( 1, cacheKey.length );
|
||||
assertEquals( it.getName(), cacheKey[0] );
|
||||
assertNotNull( entries.get( cacheKey ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-7278" )
|
||||
public void testInsertedNaturalIdCachedAfterTransactionSuccess() {
|
||||
|
|
Loading…
Reference in New Issue