Examples of CollectionStatistics


Examples of org.hibernate.stat.CollectionStatistics

    container.getContents().add( c1 );
    session.save( container );
    session.getTransaction().commit();
    session.close();

    CollectionStatistics stats =  sfi().getStatistics().getCollectionStatistics( Container.class.getName() + ".contents" );
    long recreateCount = stats.getRecreateCount();
    long updateCount = stats.getUpdateCount();

    container.setName( "another name" );

    session = openSession();
    session.beginTransaction();
    container = ( Container ) session.merge( container );
    session.getTransaction().commit();
    session.close();

    assertEquals( 1, container.getContents().size() );
    assertEquals( recreateCount, stats.getRecreateCount() );
    assertEquals( updateCount, stats.getUpdateCount() );

    session = openSession();
    session.beginTransaction();
    container = ( Container ) session.get( Container.class, container.getId() );
    assertEquals( 1, container.getContents().size() );
View Full Code Here

Examples of org.hibernate.stat.CollectionStatistics

    container.getContents().add( c1 );
    session.save( container );
    session.getTransaction().commit();
    session.close();

    CollectionStatistics stats =  sfi().getStatistics().getCollectionStatistics( Container.class.getName() + ".contents" );
    long recreateCount = stats.getRecreateCount();
    long updateCount = stats.getUpdateCount();

    session = openSession();
    session.beginTransaction();
    container = ( Container ) session.get( Container.class, container.getId() );
    assertEquals( 1, container.getContents().size() );
    session.getTransaction().commit();
    session.close();

    assertEquals( 1, container.getContents().size() );
    assertEquals( recreateCount, stats.getRecreateCount() );
    assertEquals( updateCount, stats.getUpdateCount() );

    session = openSession();
    session.beginTransaction();
    container = ( Container ) session.get( Container.class, container.getId() );
    assertEquals( 1, container.getContents().size() );
View Full Code Here

Examples of org.hibernate.stat.CollectionStatistics

  public void testLoadingNonInverseSide() {
    prepareTestData();

    sfi().getStatistics().clear();
    CollectionStatistics userGroupStats = sfi().getStatistics()
        .getCollectionStatistics( User.class.getName() + ".groups" );
    CollectionStatistics groupUserStats = sfi().getStatistics()
        .getCollectionStatistics( Group.class.getName() + ".users" );

    Interceptor testingInterceptor = new EmptyInterceptor() {
      public String onPrepareStatement(String sql) {
        // ugh, this is the best way I could come up with to assert this.
        // unfortunately, this is highly dependent on the dialect and its
        // outer join fragment.  But at least this wil fail on the majority
        // of dialects...
        Assert.assertFalse(
            "batch load of many-to-many should use inner join",
            sql.toLowerCase().contains( "left outer join" )
        );
        return super.onPrepareStatement( sql );
      }
    };

    Session s = openSession( testingInterceptor );
    s.beginTransaction();
    List users = s.createQuery( "from User u" ).list();
    User user = ( User ) users.get( 0 );
    assertTrue( Hibernate.isInitialized( user ) );
    assertTrue( Hibernate.isInitialized( user.getGroups() ) );
    user = ( User ) users.get( 1 );
    assertTrue( Hibernate.isInitialized( user ) );
    assertTrue( Hibernate.isInitialized( user.getGroups() ) );
    assertEquals( 1, userGroupStats.getFetchCount() ); // should have been just one fetch (the batch fetch)
    assertEquals( 1, groupUserStats.getFetchCount() ); // should have been just one fetch (the batch fetch)
    s.getTransaction().commit();
    s.close();

    cleanupTestData();
  }
View Full Code Here

Examples of org.hibernate.stat.CollectionStatistics

  public void testLoadingNonInverseSide() {
    prepareTestData();

    sfi().getStatistics().clear();
    CollectionStatistics userGroupStats = sfi().getStatistics()
        .getCollectionStatistics( User.class.getName() + ".groups" );
    CollectionStatistics groupUserStats = sfi().getStatistics()
        .getCollectionStatistics( Group.class.getName() + ".users" );

    Interceptor testingInterceptor = new EmptyInterceptor() {
      public String onPrepareStatement(String sql) {
        // ugh, this is the best way I could come up with to assert this.
        // unfortunately, this is highly dependent on the dialect and its
        // outer join fragment.  But at least this wil fail on the majority
        // of dialects...
        Assert.assertFalse(
            "batch load of many-to-many should use inner join",
            sql.toLowerCase().contains( "left outer join" )
        );
        return super.onPrepareStatement( sql );
      }
    };

    Session s = openSession( testingInterceptor );
    s.beginTransaction();
    List users = s.createQuery( "from User u" ).list();
    User user = ( User ) users.get( 0 );
    assertTrue( Hibernate.isInitialized( user ) );
    assertTrue( Hibernate.isInitialized( user.getGroups() ) );
    user = ( User ) users.get( 1 );
    assertTrue( Hibernate.isInitialized( user ) );
    assertTrue( Hibernate.isInitialized( user.getGroups() ) );
    assertEquals( 1, userGroupStats.getFetchCount() ); // should have been just one fetch (the batch fetch)
    assertEquals( 1, groupUserStats.getFetchCount() ); // should have been just one fetch (the batch fetch)
    s.getTransaction().commit();
    s.close();

    cleanupTestData();
  }
View Full Code Here

Examples of org.hibernate.stat.CollectionStatistics

        this.persistenceUnitRegistry = persistenceUnitRegistry;
    }

    @Override
    protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
        CollectionStatistics statistics = collectionStatistics(operation);
        if (statistics != null) {
            handle(statistics, context, operation.require(ModelDescriptionConstants.NAME).asString());
        }
        context.stepCompleted();
    }
View Full Code Here

Examples of org.hibernate.stat.CollectionStatistics

    child.setParent( parent );
    session.save( parent );
    session.getTransaction().commit();
    session.close();

    CollectionStatistics stats =  sfi().getStatistics().getCollectionStatistics( Parent.class.getName() + ".children" );
    long recreateCount = stats.getRecreateCount();
    long updateCount = stats.getUpdateCount();

    session = openSession();
    session.beginTransaction();
    parent = ( Parent ) session.merge( parent );
    session.getTransaction().commit();
    session.close();

    assertEquals( 1, parent.getChildren().size() );
    assertEquals( recreateCount, stats.getRecreateCount() );
    assertEquals( updateCount, stats.getUpdateCount() );

    session = openSession();
    session.beginTransaction();
    parent = ( Parent ) session.get( Parent.class, "p1" );
    assertEquals( 1, parent.getChildren().size() );
View Full Code Here

Examples of org.hibernate.stat.CollectionStatistics

    child.setParent( parent );
    session.save( parent );
    session.getTransaction().commit();
    session.close();

    CollectionStatistics stats =  sfi().getStatistics().getCollectionStatistics( Parent.class.getName() + ".children" );
    long recreateCount = stats.getRecreateCount();
    long updateCount = stats.getUpdateCount();

    session = openSession();
    session.beginTransaction();
    parent = ( Parent ) session.get( Parent.class, "p1" );
    assertEquals( 1, parent.getChildren().size() );
    session.getTransaction().commit();
    session.close();

    assertEquals( 1, parent.getChildren().size() );
    assertEquals( recreateCount, stats.getRecreateCount() );
    assertEquals( updateCount, stats.getUpdateCount() );

    session = openSession();
    session.beginTransaction();
    assertEquals( 1, parent.getChildren().size() );
    session.delete( parent );
View Full Code Here

Examples of org.hibernate.stat.CollectionStatistics

    container.getContents().add( c1 );
    session.save( container );
    session.getTransaction().commit();
    session.close();

    CollectionStatistics stats =  sfi().getStatistics().getCollectionStatistics( Container.class.getName() + ".contents" );
    long recreateCount = stats.getRecreateCount();
    long updateCount = stats.getUpdateCount();

    container.setName( "another name" );

    session = openSession();
    session.beginTransaction();
    container = ( Container ) session.merge( container );
    session.getTransaction().commit();
    session.close();

    assertEquals( 1, container.getContents().size() );
    assertEquals( recreateCount, stats.getRecreateCount() );
    assertEquals( updateCount, stats.getUpdateCount() );

    session = openSession();
    session.beginTransaction();
    container = ( Container ) session.get( Container.class, container.getId() );
    assertEquals( 1, container.getContents().size() );
View Full Code Here

Examples of org.hibernate.stat.CollectionStatistics

    container.getContents().add( c1 );
    session.save( container );
    session.getTransaction().commit();
    session.close();

    CollectionStatistics stats =  sfi().getStatistics().getCollectionStatistics( Container.class.getName() + ".contents" );
    long recreateCount = stats.getRecreateCount();
    long updateCount = stats.getUpdateCount();

    session = openSession();
    session.beginTransaction();
    container = ( Container ) session.get( Container.class, container.getId() );
    assertEquals( 1, container.getContents().size() );
    session.getTransaction().commit();
    session.close();

    assertEquals( 1, container.getContents().size() );
    assertEquals( recreateCount, stats.getRecreateCount() );
    assertEquals( updateCount, stats.getUpdateCount() );

    session = openSession();
    session.beginTransaction();
    container = ( Container ) session.get( Container.class, container.getId() );
    assertEquals( 1, container.getContents().size() );
View Full Code Here

Examples of org.terrier.structures.CollectionStatistics

          if (documentPointers.length > 0)
            assertEquals("Number of pointers for docid " + docid + " is incorrect", documentPointers[docid], docpointers);
          assertEquals("Document length for docid "+docid+" is incorrect", documentLengths[docid], doclen);
        }
      }
      CollectionStatistics cs = index.getCollectionStatistics();
      assertEquals("Number of documents is incorrect", cs.getNumberOfDocuments(), docid + 1);
      assertEquals("Number of pointers is incorrect", cs.getNumberOfPointers(), pointers);
      assertEquals("Number of tokens is incorrect", cs.getNumberOfTokens(), tokens);
      if (numberOfTerms > 0)
      {
        assertEquals("Not all termIds found in direct index", termIds.size(), numberOfTerms);
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.