HHH-9200 - Natural id cache statistics are not cleared
This commit is contained in:
parent
cb87d8ff7a
commit
b9dc1e3d48
|
@ -187,6 +187,7 @@ public class ConcurrentStatisticsImpl implements StatisticsImplementor, Service
|
||||||
entityStatistics.clear();
|
entityStatistics.clear();
|
||||||
collectionStatistics.clear();
|
collectionStatistics.clear();
|
||||||
queryStatistics.clear();
|
queryStatistics.clear();
|
||||||
|
naturalIdCacheStatistics.clear();
|
||||||
|
|
||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,18 @@
|
||||||
package org.hibernate.test.naturalid.mutable.cached;
|
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.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
|
|
||||||
import org.hibernate.Session;
|
|
||||||
import org.hibernate.cfg.Configuration;
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
|
||||||
import org.hibernate.testing.cache.CachingRegionFactory;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
public class CachedMutableNaturalIdStrictReadWriteTest extends
|
public class CachedMutableNaturalIdStrictReadWriteTest extends
|
||||||
CachedMutableNaturalIdTest {
|
CachedMutableNaturalIdTest {
|
||||||
|
|
||||||
|
@ -151,4 +154,27 @@ public class CachedMutableNaturalIdStrictReadWriteTest extends
|
||||||
session.getTransaction().commit();
|
session.getTransaction().commit();
|
||||||
assertEquals("In a strict access strategy we would excpect a hit here", 1, session.getSessionFactory().getStatistics().getNaturalIdCacheHitCount());
|
assertEquals("In a strict access strategy we would excpect a hit here", 1, session.getSessionFactory().getStatistics().getNaturalIdCacheHitCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestForIssue( jiraKey = "HHH-9200" )
|
||||||
|
public void testNaturalIdCacheStatisticsReset() {
|
||||||
|
final String naturalIdCacheRegion = "hibernate.test.org.hibernate.test.naturalid.mutable.cached.Another##NaturalId";
|
||||||
|
sessionFactory().getStatistics().clear();
|
||||||
|
|
||||||
|
final Session session = openSession();
|
||||||
|
session.beginTransaction();
|
||||||
|
final Another it = new Another( "IT");
|
||||||
|
session.save( it );
|
||||||
|
session.getTransaction().commit();
|
||||||
|
session.close();
|
||||||
|
|
||||||
|
NaturalIdCacheStatistics statistics = sessionFactory().getStatistics().getNaturalIdCacheStatistics( naturalIdCacheRegion );
|
||||||
|
assertEquals( 1, statistics.getPutCount() );
|
||||||
|
|
||||||
|
sessionFactory().getStatistics().clear();
|
||||||
|
|
||||||
|
// Refresh statistics reference.
|
||||||
|
statistics = sessionFactory().getStatistics().getNaturalIdCacheStatistics( naturalIdCacheRegion );
|
||||||
|
assertEquals( 0, statistics.getPutCount() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue