@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), 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.getUpdateCount() : 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.getUpdateCount() : 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(); }
@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(); }
long updateCount = stats.getUpdateCount(); assertEquals( updateCount, stats.getUpdateCount() );
long updateCount = stats.getUpdateCount(); assertEquals( updateCount, stats.getUpdateCount() );
@Override protected void handle(CollectionStatistics statistics, OperationContext context, String attributeName) { long count = statistics.getUpdateCount(); context.getResult().set(count); } };
@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.getUpdateCount() : 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.getUpdateCount() : 0); } };
@Override public Object invoke(Object... args) { CollectionStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getUpdateCount() : 0); } };
public static String[] getCollectionStatistics(final SessionFactory sessionFactory, final String collectionRoleName) { if (isNull(sessionFactory)) throw new NullPointerException("Parameter sessionFactory is null"); if (isNull(collectionRoleName)) throw new NullPointerException("Parameter collectionRoleName is null"); if (collectionRoleName.isEmpty()) throw new IllegalArgumentException("Parameter collectionRoleName is a empty String"); final Statistics sfstats = sessionFactory.getStatistics(); if (!ArrayUtils.contains(sfstats.getCollectionRoleNames(), collectionRoleName)) throw new IllegalArgumentException("Collection Role " + collectionRoleName + " is not managed by given SessionFactory"); final CollectionStatistics stats = sfstats.getCollectionStatistics(collectionRoleName); return new String[] { "+ Collection Statistics: " + collectionRoleName, "+", "+ Fetched: " + stats.getFetchCount(), "+ Recreated: " + stats.getRecreateCount(), "+ Loaded: " + stats.getLoadCount(), "+ Updated: " + stats.getUpdateCount(), "+ Removed: " + stats.getRemoveCount(), "+", "+" }; }
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(); }
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(); }
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(); }
private void addCollectionStats(List<ApplicationStat> res, Statistics stats) { addStat(res, "collection/total/fetches", stats.getCollectionFetchCount()); addStat(res, "collection/total/loads", stats.getCollectionLoadCount()); addStat(res, "collection/total/recreates", stats.getCollectionRecreateCount()); addStat(res, "collection/total/removes", stats.getCollectionRemoveCount()); addStat(res, "collection/total/updates", stats.getCollectionUpdateCount()); for (String collectionRole : stats.getCollectionRoleNames()) { CollectionStatistics collStats = stats.getCollectionStatistics(collectionRole); addStat(res, "collection/" + collectionRole + "/fetches", collStats.getFetchCount()); addStat(res, "collection/" + collectionRole + "/loads", collStats.getLoadCount()); addStat(res, "collection/" + collectionRole + "/recreates", collStats.getRecreateCount()); addStat(res, "collection/" + collectionRole + "/removes", collStats.getRemoveCount()); addStat(res, "collection/" + collectionRole + "/update", collStats.getUpdateCount()); } }