Java Code Examples for org.hibernate.stat.Statistics#logSummary()
The following examples show how to use
org.hibernate.stat.Statistics#logSummary() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReadWriteTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testQuery() { Statistics stats = sessionFactory().getStatistics(); Session s = openSession(); s.beginTransaction(); ItemReadWrite item = new ItemReadWrite("data"); item.getEntries().addAll(Arrays.asList("a", "b", "c")); s.save(item); s.flush(); s.getTransaction().commit(); s = openSession(); s.beginTransaction(); Query query = s.getNamedQuery("testQuery"); query.setCacheable(true); query.setCacheRegion("myTestQuery"); query.setParameter("name", "data"); item = (ItemReadWrite) query.uniqueResult(); s.getTransaction().commit(); s.close(); Assert.assertEquals(1, stats.getSecondLevelCacheStatistics("myTestQuery").getPutCount()); s = openSession(); s.beginTransaction(); Query query2 = s.getNamedQuery("testQuery"); query2.setCacheable(true); query2.setCacheRegion("myTestQuery"); query2.setParameter("name", "data"); item = (ItemReadWrite) query2.uniqueResult(); s.delete(item); s.getTransaction().commit(); s.close(); Assert.assertEquals(1, stats.getSecondLevelCacheStatistics("myTestQuery").getHitCount()); stats.logSummary(); }
Example 2
Source File: TransactionalTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testQuery() { Statistics stats = sessionFactory().getStatistics(); Session s = openSession(); s.beginTransaction(); ItemTransactional item = new ItemTransactional("data"); item.getEntries().addAll(Arrays.asList("a", "b", "c")); s.save(item); s.flush(); s.getTransaction().commit(); s = openSession(); s.beginTransaction(); Query query = s.getNamedQuery("testQuery"); query.setCacheable(true); query.setCacheRegion("myTestQuery"); query.setParameter("name", "data"); item = (ItemTransactional) query.uniqueResult(); s.getTransaction().commit(); s.close(); Assert.assertEquals(1, stats.getSecondLevelCacheStatistics("myTestQuery").getPutCount()); s = openSession(); s.beginTransaction(); Query query2 = s.getNamedQuery("testQuery"); query2.setCacheable(true); query2.setCacheRegion("myTestQuery"); query2.setParameter("name", "data"); item = (ItemTransactional) query2.uniqueResult(); s.delete(item); s.getTransaction().commit(); s.close(); Assert.assertEquals(1, stats.getSecondLevelCacheStatistics("myTestQuery").getHitCount()); stats.logSummary(); }
Example 3
Source File: ReadWriteTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testQuery() { Statistics stats = sessionFactory().getStatistics(); Session s = openSession(); s.beginTransaction(); ItemReadWrite item = new ItemReadWrite("data"); item.getEntries().addAll(Arrays.asList("a", "b", "c")); s.save(item); s.flush(); s.getTransaction().commit(); s = openSession(); s.beginTransaction(); Query query = s.getNamedQuery("testQuery"); query.setCacheable(true); query.setCacheRegion("myTestQuery"); query.setParameter("name", "data"); item = (ItemReadWrite) query.uniqueResult(); s.getTransaction().commit(); s.close(); Assert.assertEquals(1, stats.getSecondLevelCacheStatistics("myTestQuery").getPutCount()); s = openSession(); s.beginTransaction(); Query query2 = s.getNamedQuery("testQuery"); query2.setCacheable(true); query2.setCacheRegion("myTestQuery"); query2.setParameter("name", "data"); item = (ItemReadWrite) query2.uniqueResult(); s.delete(item); s.getTransaction().commit(); s.close(); Assert.assertEquals(1, stats.getSecondLevelCacheStatistics("myTestQuery").getHitCount()); stats.logSummary(); }
Example 4
Source File: TransactionalTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testQuery() { Statistics stats = sessionFactory().getStatistics(); Session s = openSession(); s.beginTransaction(); ItemTransactional item = new ItemTransactional("data"); item.getEntries().addAll(Arrays.asList("a", "b", "c")); s.save(item); s.flush(); s.getTransaction().commit(); s = openSession(); s.beginTransaction(); Query query = s.getNamedQuery("testQuery"); query.setCacheable(true); query.setCacheRegion("myTestQuery"); query.setParameter("name", "data"); item = (ItemTransactional) query.uniqueResult(); s.getTransaction().commit(); s.close(); Assert.assertEquals(1, stats.getSecondLevelCacheStatistics("myTestQuery").getPutCount()); s = openSession(); s.beginTransaction(); Query query2 = s.getNamedQuery("testQuery"); query2.setCacheable(true); query2.setCacheRegion("myTestQuery"); query2.setParameter("name", "data"); item = (ItemTransactional) query2.uniqueResult(); s.delete(item); s.getTransaction().commit(); s.close(); Assert.assertEquals(1, stats.getSecondLevelCacheStatistics("myTestQuery").getHitCount()); stats.logSummary(); }
Example 5
Source File: ReadWriteTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testQuery() { Statistics stats = sessionFactory().getStatistics(); Session s = openSession(); s.beginTransaction(); ItemReadWrite item = new ItemReadWrite("data"); item.getEntries().addAll(Arrays.asList("a", "b", "c")); s.save(item); s.flush(); s.getTransaction().commit(); s = openSession(); s.beginTransaction(); Query query = s.getNamedQuery("testQuery"); query.setCacheable(true); query.setCacheRegion("myTestQuery"); query.setParameter("name", "data"); item = (ItemReadWrite) query.uniqueResult(); s.getTransaction().commit(); s.close(); Assert.assertEquals(1, stats.getSecondLevelCacheStatistics("myTestQuery").getPutCount()); s = openSession(); s.beginTransaction(); Query query2 = s.getNamedQuery("testQuery"); query2.setCacheable(true); query2.setCacheRegion("myTestQuery"); query2.setParameter("name", "data"); item = (ItemReadWrite) query2.uniqueResult(); s.delete(item); s.getTransaction().commit(); s.close(); Assert.assertEquals(1, stats.getSecondLevelCacheStatistics("myTestQuery").getHitCount()); stats.logSummary(); }
Example 6
Source File: TransactionalTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testQuery() { Statistics stats = sessionFactory().getStatistics(); Session s = openSession(); s.beginTransaction(); ItemTransactional item = new ItemTransactional("data"); item.getEntries().addAll(Arrays.asList("a", "b", "c")); s.save(item); s.flush(); s.getTransaction().commit(); s = openSession(); s.beginTransaction(); Query query = s.getNamedQuery("testQuery"); query.setCacheable(true); query.setCacheRegion("myTestQuery"); query.setParameter("name", "data"); item = (ItemTransactional) query.uniqueResult(); s.getTransaction().commit(); s.close(); Assert.assertEquals(1, stats.getSecondLevelCacheStatistics("myTestQuery").getPutCount()); s = openSession(); s.beginTransaction(); Query query2 = s.getNamedQuery("testQuery"); query2.setCacheable(true); query2.setCacheRegion("myTestQuery"); query2.setParameter("name", "data"); item = (ItemTransactional) query2.uniqueResult(); s.delete(item); s.getTransaction().commit(); s.close(); Assert.assertEquals(1, stats.getSecondLevelCacheStatistics("myTestQuery").getHitCount()); stats.logSummary(); }
Example 7
Source File: ReadWriteTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testQuery() { Statistics stats = sessionFactory().getStatistics(); Session s = openSession(); s.beginTransaction(); ItemReadWrite item = new ItemReadWrite("data"); item.getEntries().addAll(Arrays.asList("a", "b", "c")); s.save(item); s.flush(); s.getTransaction().commit(); s = openSession(); s.beginTransaction(); Query query = s.getNamedQuery("testQuery"); query.setCacheable(true); query.setCacheRegion("myTestQuery"); query.setParameter("name", "data"); item = (ItemReadWrite) query.uniqueResult(); s.getTransaction().commit(); s.close(); Assert.assertEquals(1, stats.getSecondLevelCacheStatistics("myTestQuery").getPutCount()); s = openSession(); s.beginTransaction(); Query query2 = s.getNamedQuery("testQuery"); query2.setCacheable(true); query2.setCacheRegion("myTestQuery"); query2.setParameter("name", "data"); item = (ItemReadWrite) query2.uniqueResult(); s.delete(item); s.getTransaction().commit(); s.close(); Assert.assertEquals(1, stats.getSecondLevelCacheStatistics("myTestQuery").getHitCount()); stats.logSummary(); }
Example 8
Source File: TransactionalTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testQuery() { Statistics stats = sessionFactory().getStatistics(); Session s = openSession(); s.beginTransaction(); ItemTransactional item = new ItemTransactional("data"); item.getEntries().addAll(Arrays.asList("a", "b", "c")); s.save(item); s.flush(); s.getTransaction().commit(); s = openSession(); s.beginTransaction(); Query query = s.getNamedQuery("testQuery"); query.setCacheable(true); query.setCacheRegion("myTestQuery"); query.setParameter("name", "data"); item = (ItemTransactional) query.uniqueResult(); s.getTransaction().commit(); s.close(); Assert.assertEquals(1, stats.getSecondLevelCacheStatistics("myTestQuery").getPutCount()); s = openSession(); s.beginTransaction(); Query query2 = s.getNamedQuery("testQuery"); query2.setCacheable(true); query2.setCacheRegion("myTestQuery"); query2.setParameter("name", "data"); item = (ItemTransactional) query2.uniqueResult(); s.delete(item); s.getTransaction().commit(); s.close(); Assert.assertEquals(1, stats.getSecondLevelCacheStatistics("myTestQuery").getHitCount()); stats.logSummary(); }
Example 9
Source File: CollectionTest.java From redisson with Apache License 2.0 | 4 votes |
@Test public void testQuery() { Statistics stats = sessionFactory().getStatistics(); Session s = openSession(); s.beginTransaction(); A a = new A(); a.id = 1L; a.uniqueField = "1"; B b = new B(); b.id = 1L; s.save(b); a.bs.add(b); s.save(a); s.flush(); s.getTransaction().commit(); s = openSession(); s.beginTransaction(); A a1 = s.get(A.class, 1L); System.out.println("here1"); assertThat(a1.bs).hasSize(1); s.getTransaction().commit(); Assert.assertEquals(0, stats.getSecondLevelCacheStatistics("org.redisson.hibernate.CollectionTest$A.bs").getHitCount()); s = openSession(); s.beginTransaction(); A a2 = s.get(A.class, 1L); B b2 = a2.bs.iterator().next(); assertThat(a2.bs.size()).isEqualTo(1); s.getTransaction().commit(); s.close(); Assert.assertEquals(1, stats.getSecondLevelCacheStatistics("org.redisson.hibernate.CollectionTest$A.bs").getHitCount()); stats.logSummary(); }
Example 10
Source File: CollectionTest.java From redisson with Apache License 2.0 | 4 votes |
@Test public void testQuery() { Statistics stats = sessionFactory().getStatistics(); Session s = openSession(); s.beginTransaction(); A a = new A(); a.id = 1L; a.uniqueField = "1"; B b = new B(); b.id = 1L; s.save(b); a.bs.add(b); s.save(a); s.flush(); s.getTransaction().commit(); s = openSession(); s.beginTransaction(); A a1 = s.get(A.class, 1L); System.out.println("here1"); assertThat(a1.bs).hasSize(1); s.getTransaction().commit(); Assert.assertEquals(0, stats.getSecondLevelCacheStatistics("org.redisson.hibernate.CollectionTest$A.bs").getHitCount()); s = openSession(); s.beginTransaction(); A a2 = s.get(A.class, 1L); B b2 = a2.bs.iterator().next(); assertThat(a2.bs.size()).isEqualTo(1); s.getTransaction().commit(); s.close(); Assert.assertEquals(1, stats.getSecondLevelCacheStatistics("org.redisson.hibernate.CollectionTest$A.bs").getHitCount()); stats.logSummary(); }
Example 11
Source File: CollectionTest.java From redisson with Apache License 2.0 | 4 votes |
@Test public void testQuery() { Statistics stats = sessionFactory().getStatistics(); Session s = openSession(); s.beginTransaction(); A a = new A(); a.id = 1L; a.uniqueField = "1"; B b = new B(); b.id = 1L; s.save(b); a.bs.add(b); s.save(a); s.flush(); s.getTransaction().commit(); s = openSession(); s.beginTransaction(); A a1 = s.get(A.class, 1L); System.out.println("here1"); assertThat(a1.bs).hasSize(1); s.getTransaction().commit(); Assert.assertEquals(0, stats.getSecondLevelCacheStatistics("org.redisson.hibernate.CollectionTest$A.bs").getHitCount()); s = openSession(); s.beginTransaction(); A a2 = s.get(A.class, 1L); B b2 = a2.bs.iterator().next(); assertThat(a2.bs.size()).isEqualTo(1); s.getTransaction().commit(); s.close(); Assert.assertEquals(1, stats.getSecondLevelCacheStatistics("org.redisson.hibernate.CollectionTest$A.bs").getHitCount()); stats.logSummary(); }