本文整理了Java中org.hibernate.stat.Statistics.getNaturalIdCacheHitCount()
方法的一些代码示例,展示了Statistics.getNaturalIdCacheHitCount()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Statistics.getNaturalIdCacheHitCount()
方法的具体详情如下:
包路径:org.hibernate.stat.Statistics
类名称:Statistics
方法名:getNaturalIdCacheHitCount
[英]Get the global number of cached natural id lookups successfully retrieved from cache
[中]获取从缓存中成功检索到的缓存自然id查找的全局数量
代码示例来源:origin: prometheus/client_java
@Override
public double getValue(Statistics statistics) {
return statistics.getNaturalIdCacheHitCount();
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
@TestForIssue( jiraKey = "HHH-7278" )
public void testInsertedNaturalIdCachedAfterTransactionSuccess() {
Session session = openSession();
session.getSessionFactory().getStatistics().clear();
session.beginTransaction();
Another it = new Another( "it");
session.save( it );
session.flush();
session.getTransaction().commit();
session.close();
session = openSession();
session.beginTransaction();
it = (Another) session.bySimpleNaturalId(Another.class).load("it");
assertNotNull(it);
session.delete(it);
session.getTransaction().commit();
assertEquals(1, session.getSessionFactory().getStatistics().getNaturalIdCacheHitCount());
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
@TestForIssue( jiraKey = "HHH-7309" )
public void testInsertUpdateEntity_NaturalIdCachedAfterTransactionSuccess() {
Session session = openSession();
session.getSessionFactory().getStatistics().clear();
session.beginTransaction();
Another it = new Another( "it");
session.save( it ); // schedules an InsertAction
it.setSurname("1234"); // schedules an UpdateAction, without bug-fix
// this will re-cache natural-id with identical key and at same time invalidate it
session.flush();
session.getTransaction().commit();
session.close();
session = openSession();
session.beginTransaction();
it = (Another) session.bySimpleNaturalId(Another.class).load("it");
assertNotNull(it);
session.delete(it);
session.getTransaction().commit();
assertEquals("In a strict access strategy we would excpect a hit here", 1, session.getSessionFactory().getStatistics().getNaturalIdCacheHitCount());
}
代码示例来源:origin: hibernate/hibernate-orm
session.close();
assertEquals(1, session.getSessionFactory().getStatistics().getNaturalIdCacheHitCount());
代码示例来源:origin: hibernate/hibernate-orm
@Test
@TestForIssue( jiraKey = "HHH-7278" )
public void testInsertedNaturalIdNotCachedAfterTransactionFailure() {
Session session = openSession();
session.getSessionFactory().getStatistics().clear();
session.beginTransaction();
Another it = new Another( "it");
session.save( it );
session.flush();
session.getTransaction().rollback();
session.close();
session = openSession();
session.beginTransaction();
it = (Another) session.bySimpleNaturalId(Another.class).load("it");
assertNull(it);
assertEquals(0, session.getSessionFactory().getStatistics().getNaturalIdCacheHitCount());
}
代码示例来源:origin: hibernate/hibernate-orm
session.close();
assertEquals(0, session.getSessionFactory().getStatistics().getNaturalIdCacheHitCount());
代码示例来源:origin: hibernate/hibernate-orm
assertEquals(
"Cache hits should be empty", 0, stats
.getNaturalIdCacheHitCount()
);
assertEquals(
"Cache hits should be empty", 0, stats
.getNaturalIdCacheHitCount()
);
assertEquals(
assertEquals(
"Cache hits should be empty", 0, stats
.getNaturalIdCacheHitCount()
);
assertEquals(
代码示例来源:origin: hibernate/hibernate-orm
stats.setStatisticsEnabled( true );
stats.clear();
assertEquals( "Cache hits should be empty", 0, stats.getNaturalIdCacheHitCount() );
assertEquals( "Cache puts should be empty", 0, stats.getNaturalIdCachePutCount() );
assertEquals( "NaturalId Cache Hits", 0, stats.getNaturalIdCacheHitCount() );
assertEquals( "NaturalId Cache Misses", 1, stats.getNaturalIdCacheMissCount() );
assertEquals( "NaturalId Cache Puts", 1, stats.getNaturalIdCachePutCount() );
assertEquals( "NaturalId Cache Hits", 0, stats.getNaturalIdCacheHitCount() );
assertEquals( "NaturalId Cache Misses", 1, stats.getNaturalIdCacheMissCount() );
assertEquals( "NaturalId Cache Puts", 1, stats.getNaturalIdCachePutCount() );
代码示例来源:origin: hibernate/hibernate-orm
it = session.bySimpleNaturalId(Another.class).load("it");
assertNull(it);
assertEquals( 0, session.getSessionFactory().getStatistics().getNaturalIdCacheHitCount() );
it = session.byId(Another.class).load(id);
session.delete(it);
代码示例来源:origin: hibernate/hibernate-orm
1, s.getSessionFactory().getStatistics().getNaturalIdCacheHitCount()
);
代码示例来源:origin: hibernate/hibernate-orm
1, s.getSessionFactory().getStatistics().getNaturalIdCacheHitCount()
);
s.createQuery( "delete from D" ).executeUpdate();
代码示例来源:origin: hibernate/hibernate-orm
1, s.getSessionFactory().getStatistics().getNaturalIdCacheHitCount()
);
s.createQuery( "delete from A" ).executeUpdate();
代码示例来源:origin: hibernate/hibernate-orm
stats.clear();
assertEquals( "NaturalId cache puts should be zero", 0, stats.getNaturalIdCachePutCount() );
assertEquals( "NaturalId cache hits should be zero", 0, stats.getNaturalIdCacheHitCount() );
assertEquals( "NaturalId Cache Puts", 0, stats.getNaturalIdCachePutCount() );
assertEquals( "NaturalId cache misses should be zero", 0, stats.getNaturalIdCacheMissCount() );
assertEquals( "NaturalId Cache Hits", 0, stats.getNaturalIdCacheHitCount() );
assertEquals( "NaturalId Cache Misses", 1, stats.getNaturalIdCacheMissCount() );
assertEquals( "NaturalId Cache Puts", 2, stats.getNaturalIdCachePutCount() ); // one for Citizen, one for NaturalIdOnManyToOne
assertEquals( "NaturalId Cache Hits", 0, stats.getNaturalIdCacheHitCount() );
assertEquals( "NaturalId Cache Misses", 1, stats.getNaturalIdCacheMissCount() );
assertEquals( "NaturalId Cache Puts", 2, stats.getNaturalIdCachePutCount() );
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testNaturalIdLoaderNotCached() {
saveSomeCitizens();
Session s = openSession();
Transaction tx = s.beginTransaction();
State france = this.getState( s, "Ile de France" );
final NaturalIdLoadAccess naturalIdLoader = s.byNaturalId( Citizen.class );
naturalIdLoader.using( "ssn", "1234" ).using( "state", france );
//NaturalId cache gets populated during entity loading, need to clear it out
this.cleanupCache();
Statistics stats = sessionFactory().getStatistics();
stats.setStatisticsEnabled( true );
stats.clear();
assertEquals( "NaturalId Cache Hits", 0, stats.getNaturalIdCacheHitCount() );
assertEquals( "NaturalId Cache Misses", 0, stats.getNaturalIdCacheMissCount() );
assertEquals( "NaturalId Cache Puts", 0, stats.getNaturalIdCachePutCount() );
assertEquals( "NaturalId Cache Queries", 0, stats.getNaturalIdQueryExecutionCount() );
// first query
Citizen citizen = (Citizen)naturalIdLoader.load();
assertNotNull( citizen );
assertEquals( "NaturalId Cache Hits", 0, stats.getNaturalIdCacheHitCount() );
assertEquals( "NaturalId Cache Misses", 1, stats.getNaturalIdCacheMissCount() );
assertEquals( "NaturalId Cache Puts", 1, stats.getNaturalIdCachePutCount() );
assertEquals( "NaturalId Cache Queries", 1, stats.getNaturalIdQueryExecutionCount() );
// cleanup
tx.rollback();
s.close();
}
代码示例来源:origin: hibernate/hibernate-orm
stats.clear();
assertEquals( "NaturalId Cache Hits", 0, stats.getNaturalIdCacheHitCount() );
assertEquals( "NaturalId Cache Misses", 0, stats.getNaturalIdCacheMissCount() );
assertEquals( "NaturalId Cache Puts", 0, stats.getNaturalIdCachePutCount() );
assertEquals( "NaturalId Cache Hits", 0, stats.getNaturalIdCacheHitCount() );
assertEquals( "NaturalId Cache Misses", 0, stats.getNaturalIdCacheMissCount() );
assertEquals( "NaturalId Cache Puts", 2, stats.getNaturalIdCachePutCount() );
assertEquals( "NaturalId Cache Hits", 1, stats.getNaturalIdCacheHitCount() );
assertEquals( "NaturalId Cache Misses", 0, stats.getNaturalIdCacheMissCount() );
assertEquals( "NaturalId Cache Puts", 0, stats.getNaturalIdCachePutCount() );
assertEquals( "NaturalId Cache Hits", 0, stats.getNaturalIdCacheHitCount() );
assertEquals( "NaturalId Cache Misses", 0, stats.getNaturalIdCacheMissCount() );
assertEquals( "NaturalId Cache Puts", 1, stats.getNaturalIdCachePutCount() );
assertEquals( "NaturalId Cache Hits", 1, stats.getNaturalIdCacheHitCount() );
assertEquals( "NaturalId Cache Misses", 0, stats.getNaturalIdCacheMissCount() );
assertEquals( "NaturalId Cache Puts", 0, stats.getNaturalIdCachePutCount() );
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
public long getNaturalIdCacheHitCount() {
return stats.getNaturalIdCacheHitCount();
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate
public long getNaturalIdCacheHitCount() {
return stats.getNaturalIdCacheHitCount();
}
代码示例来源:origin: org.infinispan/infinispan-hibernate-cache-commons
assertEquals(
"Cache hits should be empty", 0, stats
.getNaturalIdCacheHitCount()
);
assertEquals( "NaturalId Cache Hits", 0, stats.getNaturalIdCacheHitCount() );
assertEquals( "NaturalId Cache Misses", 1, stats.getNaturalIdCacheMissCount() );
assertEquals( "NaturalId Cache Puts", 1, stats.getNaturalIdCachePutCount() );
assertEquals( "NaturalId Cache Hits", 0, stats.getNaturalIdCacheHitCount() );
assertEquals( "NaturalId Cache Misses", 1, stats.getNaturalIdCacheMissCount() );
assertEquals( "NaturalId Cache Puts", 1, stats.getNaturalIdCachePutCount() );
代码示例来源:origin: org.infinispan/infinispan-hibernate-cache-commons
stats.clear();
assertEquals( "NaturalId Cache Hits", 0, stats.getNaturalIdCacheHitCount() );
assertEquals( "NaturalId Cache Misses", 0, stats.getNaturalIdCacheMissCount() );
assertEquals( "NaturalId Cache Puts", 0, stats.getNaturalIdCachePutCount() );
assertEquals( "NaturalId Cache Hits", 0, stats.getNaturalIdCacheHitCount() );
assertEquals( "NaturalId Cache Misses", 0, stats.getNaturalIdCacheMissCount() );
assertEquals( "NaturalId Cache Puts", 2, stats.getNaturalIdCachePutCount() );
assertEquals("NaturalId Cache Hits", 1, stats.getNaturalIdCacheHitCount());
assertEquals("NaturalId Cache Misses", 0, stats.getNaturalIdCacheMissCount());
assertEquals("NaturalId Cache Puts", 0, stats.getNaturalIdCachePutCount());
assertEquals( "NaturalId Cache Hits", 0, stats.getNaturalIdCacheHitCount() );
assertEquals( "NaturalId Cache Misses", 0, stats.getNaturalIdCacheMissCount() );
assertEquals( "NaturalId Cache Puts", 1, stats.getNaturalIdCachePutCount() );
assertEquals( "NaturalId Cache Hits", 1, stats.getNaturalIdCacheHitCount() );
assertEquals( "NaturalId Cache Misses", 0, stats.getNaturalIdCacheMissCount() );
assertEquals( "NaturalId Cache Puts", 0, stats.getNaturalIdCachePutCount() );
内容来源于网络,如有侵权,请联系作者删除!