private void checkEmptyAuditSessionCache(Session session, String... auditEntityNames) { List<String> entityNames = Arrays.asList(auditEntityNames); PersistenceContext persistenceContext = ((SessionImplementor) session).getPersistenceContext(); for (Object entry : persistenceContext.getEntityEntries().values()) { EntityEntry entityEntry = (EntityEntry) entry; if (entityNames.contains(entityEntry.getEntityName())) { assert false : "Audit data shall not be stored in the session level cache. This causes performance issues."; } Assert.assertFalse( "Revision entity shall not be stored in the session level cache. This causes performance issues.", DefaultRevisionEntity.class.getName().equals(entityEntry.getEntityName())); } }
@SuppressWarnings(value = {"unchecked"}) private void logFlushResults(FlushEvent event) { if (!LOG.isDebugEnabled()) { return; } final EventSource session = event.getSession(); final PersistenceContext persistenceContext = session.getPersistenceContext(); LOG.debugf( "Flushed: %s insertions, %s updates, %s deletions to %s objects", session.getActionQueue().numberOfInsertions(), session.getActionQueue().numberOfUpdates(), session.getActionQueue().numberOfDeletions(), persistenceContext.getEntityEntries().size()); LOG.debugf( "Flushed: %s (re)creations, %s updates, %s removals to %s collections", session.getActionQueue().numberOfCollectionCreations(), session.getActionQueue().numberOfCollectionUpdates(), session.getActionQueue().numberOfCollectionRemovals(), persistenceContext.getCollectionEntries().size()); new EntityPrinter(session.getFactory()) .toString(persistenceContext.getEntitiesByKey().entrySet()); }