@Override public Object invoke(Object... args) { CollectionStatistics statistics = getStatistics( getEntityManagerFactory( args ), getStatisticName( args ) ); return Long.valueOf( statistics != null ? statistics.getFetchCount() : 0 ); } };
@Override public Object invoke(Object... args) { CollectionStatistics statistics = getStatistics( getEntityManagerFactory( args ), getStatisticName( args ) ); return Long.valueOf( statistics != null ? statistics.getUpdateCount() : 0 ); } };
@Override public Object invoke(Object... args) { CollectionStatistics statistics = getStatistics( getEntityManagerFactory( args ), getStatisticName( args ) ); return Long.valueOf( statistics != null ? statistics.getLoadCount() : 0 ); } };
public CollectionStats(String name, CollectionStatistics src) { this(name); this.loadCount = src.getLoadCount(); this.fetchCount = src.getFetchCount(); this.updateCount = src.getUpdateCount(); this.removeCount = src.getRemoveCount(); this.recreateCount = src.getRecreateCount(); }
@Override public Object invoke(Object... args) { CollectionStatistics statistics = getStatistics( getEntityManagerFactory( args ), getStatisticName( args ) ); return Long.valueOf( statistics != null ? statistics.getRemoveCount() : 0 ); } };
@Test public void testCollectionMerging() { Session session = openSession(); session.beginTransaction(); Parent parent = new Parent( "p1" ); Child child = new Child( "c1" ); parent.getChildren().add( child ); child.setParent( parent ); session.save( parent ); session.getTransaction().commit(); session.close(); CollectionStatistics stats = sessionFactory().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() ); session.delete( parent ); session.getTransaction().commit(); session.close(); }
@Override protected void handle(CollectionStatistics statistics, OperationContext context, String attributeName) { long count = statistics.getRecreateCount(); context.getResult().set(count); } };
public CollectionStats(String name, CollectionStatistics src) { this(name); this.loadCount = src.getLoadCount(); this.fetchCount = src.getFetchCount(); this.updateCount = src.getUpdateCount(); this.removeCount = src.getRemoveCount(); this.recreateCount = src.getRecreateCount(); }
@Override public Object invoke(Object... args) { CollectionStatistics statistics = getStatistics( getEntityManagerFactory( args ), getStatisticName( args ) ); return Long.valueOf( statistics != null ? statistics.getRemoveCount() : 0 ); } };
@Test public void testCollectiondirtyChecking() { Session session = openSession(); session.beginTransaction(); Parent parent = new Parent( "p1" ); Child child = new Child( "c1" ); parent.getChildren().add( child ); child.setParent( parent ); session.save( parent ); session.getTransaction().commit(); session.close(); CollectionStatistics stats = sessionFactory().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 ); session.getTransaction().commit(); session.close(); }
public CollectionStats(String name, CollectionStatistics src) { this(name); this.loadCount = src.getLoadCount(); this.fetchCount = src.getFetchCount(); this.updateCount = src.getUpdateCount(); this.removeCount = src.getRemoveCount(); this.recreateCount = src.getRecreateCount(); }
@Override public Object invoke(Object... args) { CollectionStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getRemoveCount() : 0); } };
@Override public Object invoke(Object... args) { CollectionStatistics statistics = getStatistics(getEntityManagerFactory(args), getPathAddress(args)); return Long.valueOf(statistics != null ? statistics.getFetchCount() : 0); } };
@Override public Object invoke(Object... args) { CollectionStatistics statistics = getStatistics(getEntityManagerFactory(args), getPathAddress(args)); return Long.valueOf(statistics != null ? statistics.getUpdateCount() : 0); } };
@Override public Object invoke(Object... args) { CollectionStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getLoadCount() : 0); } };
long recreateCount = stats.getRecreateCount(); long updateCount = stats.getUpdateCount(); assertEquals( recreateCount, stats.getRecreateCount() ); assertEquals( updateCount, stats.getUpdateCount() );
protected void logCollections(StringBuilder builder, String lineSep, Statistics stats) { builder.append("Important collections statistics: ").append(lineSep); for (String col : stats.getCollectionRoleNames()) { CollectionStatistics collectionStats = stats.getCollectionStatistics(col); if (collectionStats.getRecreateCount() > LIMIT || collectionStats.getUpdateCount() > LIMIT || collectionStats.getRemoveCount() > LIMIT || collectionStats.getLoadCount() > LIMIT || collectionStats.getFetchCount() > LIMIT) { builder.append(col).append(" - ") .append("recreated: ").append(collectionStats.getRecreateCount()) .append(", updated: ").append(collectionStats.getUpdateCount()) .append(", removed: ").append(collectionStats.getRemoveCount()) .append(", loaded: ").append(collectionStats.getLoadCount()) .append(", fetched: ").append(collectionStats.getFetchCount()) .append(lineSep); } } builder.append(lineSep); }
@Override public Object invoke(Object... args) { CollectionStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getRemoveCount() : 0); } };
@Override public Object invoke(Object... args) { CollectionStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getFetchCount() : 0); } };
@Override public Object invoke(Object... args) { CollectionStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getUpdateCount() : 0); } };