Package org.hibernate.stat

Examples of org.hibernate.stat.SessionStatistics


    stats.setStatisticsEnabled(true);
    Continent europe = fillDb(s);
    tx.commit();
    s.clear();
    tx = s.beginTransaction();
    SessionStatistics sessionStats = s.getStatistics();
    assertEquals( 0, sessionStats.getEntityKeys().size() );
    assertEquals( 0, sessionStats.getEntityCount() );
    assertEquals( 0, sessionStats.getCollectionKeys().size() );
    assertEquals( 0, sessionStats.getCollectionCount() );
    europe = (Continent) s.get( Continent.class, europe.getId() );
    Hibernate.initialize( europe.getCountries() );
    Hibernate.initialize( europe.getCountries().iterator().next() );
    assertEquals( 2, sessionStats.getEntityKeys().size() );
    assertEquals( 2, sessionStats.getEntityCount() );
    assertEquals( 1, sessionStats.getCollectionKeys().size() );
    assertEquals( 1, sessionStats.getCollectionCount() );
    tx.commit();
    s.close();

    stats.setStatisticsEnabled( isStats);
View Full Code Here


                planet.getSatellites().addAll(satellites);

            }

            session.saveOrUpdate(planet);
            SessionStatistics stats = session.getStatistics();
            assertEquals(2, stats.getEntityKeys().size());
            assertEquals(2, stats.getEntityCount());

            // session.flush();
            // session.close();
        } catch (Exception e) {
View Full Code Here

    public SessionFactory getSessionFactory() {
        return null;
    }

    public SessionStatistics getStatistics() {
        return new SessionStatistics() {
            public int getCollectionCount() {
                return DUMMY_COLLECTION_COUNT;
            }

            @SuppressWarnings("rawtypes")
View Full Code Here

    stats.setStatisticsEnabled(true);
    Continent europe = fillDb(s);
    tx.commit();
    s.clear();
    tx = s.beginTransaction();
    SessionStatistics sessionStats = s.getStatistics();
    assertEquals( 0, sessionStats.getEntityKeys().size() );
    assertEquals( 0, sessionStats.getEntityCount() );
    assertEquals( 0, sessionStats.getCollectionKeys().size() );
    assertEquals( 0, sessionStats.getCollectionCount() );
    europe = (Continent) s.get( Continent.class, europe.getId() );
    Hibernate.initialize( europe.getCountries() );
    Hibernate.initialize( europe.getCountries().iterator().next() );
    assertEquals( 2, sessionStats.getEntityKeys().size() );
    assertEquals( 2, sessionStats.getEntityCount() );
    assertEquals( 1, sessionStats.getCollectionKeys().size() );
    assertEquals( 1, sessionStats.getCollectionCount() );
    tx.commit();
    s.close();

    stats.setStatisticsEnabled( isStats);
View Full Code Here

    stats.setStatisticsEnabled(true);
    Continent europe = fillDb(s);
    tx.commit();
    s.clear();
    tx = s.beginTransaction();
    SessionStatistics sessionStats = s.getStatistics();
    assertEquals( 0, sessionStats.getEntityKeys().size() );
    assertEquals( 0, sessionStats.getEntityCount() );
    assertEquals( 0, sessionStats.getCollectionKeys().size() );
    assertEquals( 0, sessionStats.getCollectionCount() );
    europe = (Continent) s.get( Continent.class, europe.getId() );
    Hibernate.initialize( europe.getCountries() );
    Hibernate.initialize( europe.getCountries().iterator().next() );
    assertEquals( 2, sessionStats.getEntityKeys().size() );
    assertEquals( 2, sessionStats.getEntityCount() );
    assertEquals( 1, sessionStats.getCollectionKeys().size() );
    assertEquals( 1, sessionStats.getCollectionCount() );
    tx.commit();
    s.close();

    stats.setStatisticsEnabled( isStats);
View Full Code Here

    }

    @Test
    public void secondLevelCacheAccessInSameTx() throws Exception {
        EntityManager em = super.newEntityManagerInstance();
        SessionStatistics sessionStats = getSessionStatistics(em);
        SecondLevelCacheStatistics cacheStats =
                getSecondLevelCacheStatistics(em, HPerson.class.getName());

        HPerson p = em.find(HPerson.class, 3L);
        assertThat(p.getName(), is("Bob Translator"));
View Full Code Here

    }

    @Test
    public void secondLevelCacheAccessAfterCommit() throws Exception {
        EntityManager em = super.newEntityManagerInstance();
        SessionStatistics sessionStats = getSessionStatistics(em);
        SecondLevelCacheStatistics cacheStats =
                getSecondLevelCacheStatistics(em, HPerson.class.getName());

        HPerson p = em.find(HPerson.class, 3L);
        assertThat(p.getName(), is("Bob Translator"));
View Full Code Here

                getSecondLevelCacheStatistics(em1, HPerson.class.getName());

        em1.getTransaction().begin();
        em2.getTransaction().begin();

        SessionStatistics sesStats1 = getSessionStatistics(em1), sesStats2 =
                getSessionStatistics(em2);

        // EM 1
        HPerson bobT = em1.find(HPerson.class, 3L);
        assertThat(bobT.getName(), is("Bob Translator"));
View Full Code Here

TOP

Related Classes of org.hibernate.stat.SessionStatistics

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.