@Override public Object invoke(Object... args) { org.hibernate.stat.Statistics statistics = getStatistics( getEntityManagerFactory( args ) ); return Long.valueOf( statistics != null ? statistics.getQueryCacheHitCount() : 0 ); } };
@Override public Object invoke(Object... args) { org.hibernate.stat.Statistics statistics = getStatistics(getEntityManagerFactory(args)); return Long.valueOf(statistics != null ? statistics.getQueryCacheHitCount() : 0); } };
@Override public Object invoke(Object... args) { org.hibernate.stat.Statistics statistics = getStatistics(getEntityManagerFactory(args)); return Long.valueOf(statistics != null ? statistics.getQueryCacheHitCount() : 0); } };
@Override public Object invoke(Object... args) { org.hibernate.stat.Statistics statistics = getStatistics(getEntityManagerFactory(args)); return Long.valueOf(statistics != null ? statistics.getQueryCacheHitCount() : 0); } };
@Override public Object invoke(Object... args) { org.hibernate.stat.Statistics statistics = getStatistics(getEntityManagerFactory(args)); return Long.valueOf(statistics != null ? statistics.getQueryCacheHitCount() : 0); } };
json.put("QueryExecutionMaxTime", statistics.getQueryExecutionMaxTime()); json.put("QueryExecutionMaxTimeQueryString", statistics.getQueryExecutionMaxTimeQueryString()); json.put("QueryCacheHitCount", statistics.getQueryCacheHitCount()); json.put("QueryCacheMissCount", statistics.getQueryCacheMissCount()); json.put("QueryCachePutCount", statistics.getQueryCachePutCount());
q.setParameter( "duration", 14l ); s.delete( q.list().get( 0 ) ); assertEquals( 1, stats.getQueryCacheHitCount() ); tx.commit(); s.close();
@Override public double getValue(Statistics statistics) { return statistics.getQueryCacheHitCount(); } }
q.setCacheable( true ); q.list(); assertEquals( 1, stats.getQueryCacheHitCount() ); Night n2 = (Night) ( (Object[]) result.get( 0 ) )[0]; assertEquals( n2.getDuration(), n.getDuration() );
@TestForIssue(jiraKey = "HHH-4838") @Test public void testNaturalKeyLookupWithConstraint() { Session s = openSession(); Transaction newTx = s.getTransaction(); newTx.begin(); A a1 = new A(); a1.setName( "name1" ); s.persist( a1 ); newTx.commit(); newTx = s.beginTransaction(); getCriteria( s ).add( Restrictions.isNull( "singleD" ) ).uniqueResult(); // put query-result into cache A a2 = new A(); a2.setName( "xxxxxx" ); s.persist( a2 ); newTx.commit(); // Invalidates space A in UpdateTimeStamps region newTx = s.beginTransaction(); Assert.assertTrue( s.getSessionFactory().getStatistics().isStatisticsEnabled() ); s.getSessionFactory().getStatistics().clear(); // should not produce a hit in StandardQuery cache region because there is a constraint getCriteria( s ).add( Restrictions.isNull( "singleD" ) ).uniqueResult(); Assert.assertEquals( 0, s.getSessionFactory().getStatistics().getQueryCacheHitCount() ); s.createQuery( "delete from A" ).executeUpdate(); newTx.commit(); // Shutting down the application s.close(); }
Assert.assertEquals( 0, s.getSessionFactory().getStatistics().getQueryCacheHitCount() ); s.createQuery( "delete from A" ).executeUpdate(); s.createQuery( "delete from D" ).executeUpdate();
assertEquals( 0, entityManagerFactory().unwrap( SessionFactory.class ).getStatistics().getQueryCacheHitCount() ); entityManagerFactory().unwrap( SessionFactory.class ).getStatistics().getQueryCacheHitCount() );
Assert.assertEquals( 0, s.getSessionFactory().getStatistics().getQueryCacheHitCount() ); s.createQuery( "delete from A" ).executeUpdate(); s.createQuery( "delete from D" ).executeUpdate();
public long getQueryCacheHitCount() { return stats.getQueryCacheHitCount(); } public long getQueryExecutionMaxTime() {
public long getQueryCacheHitCount() { return stats.getQueryCacheHitCount(); } public long getQueryExecutionMaxTime() {
@Override void handle(final ModelNode response, final String name, ManagementLookup stats, OperationContext context) { response.set(stats.getStatistics().getQueryCacheHitCount()); } });
@Override public Object invoke(Object... args) { org.hibernate.stat.Statistics statistics = getStatistics(getEntityManagerFactory(args)); return Long.valueOf(statistics != null ? statistics.getQueryCacheHitCount() : 0); } };
@Override public Object invoke(Object... args) { org.hibernate.stat.Statistics statistics = getStatistics(getEntityManagerFactory(args)); return Long.valueOf(statistics != null ? statistics.getQueryCacheHitCount() : 0); } };
Statistics stats = sessionFactory.getStatistics(); stats.setStatisticsEnabled(true); ... // do your work long hitCount = stats.getQueryCacheHitCount(); long missCount = stats.getQueryCacheMissCount();
public void printStats() { System.out.println("query cache put count: " + sessionFactory.getStatistics().getQueryCachePutCount()); System.out.println("query cache hit count: " + sessionFactory.getStatistics().getQueryCacheHitCount()); System.out.println("query cache miss count: " + sessionFactory.getStatistics().getQueryCacheMissCount()); }