public static String toLoggableString(CollectionKey collectionKey) { return toLoggableString( toLoggableString( collectionKey.getNavigableRole() ), collectionKey.getKey() ); }
protected void takeResponsibility(RowProcessingState rowProcessingState, CollectionKey collectionKey) { rowProcessingState.getJdbcValuesSourceProcessingState().registerLoadingCollection( collectionKey, new LoadingCollectionEntry( getCollectionDescriptor(), this, collectionKey.getKey(), collectionInstance ) ); responsible = true; }
@Override public void initializeInstance(RowProcessingState rowProcessingState) { if ( !responsible ) { return; } // the LHS key value of the association final CollectionKey collectionKey = resolveCollectionKey( rowProcessingState ); // the RHS key value of the association final Object keyCollectionValue = getKeyCollectionValue(); if ( keyCollectionValue != null ) { // the row contains an element in the collection... if ( CollectionLoadingLogger.DEBUG_ENABLED ) { CollectionLoadingLogger.INSTANCE.debugf( "(%s) Reading element from row for collection [%s] -> %s", StringHelper.collapse( this.getClass().getName() ), LoggingHelper.toLoggableString( getNavigablePath(), collectionKey.getKey() ), LoggingHelper.toLoggableString( collectionInstance ) ); } readCollectionRow( rowProcessingState ); } }
@Override public int prepare(long id, Serializable context) { Context ctx = (Context) context; DB db = (DB) ctx.get(TxnConstants.DB); Session session = db.session(); SessionStatistics statistics = session.getStatistics(); Set<EntityKey> entityKeys = statistics.getEntityKeys(); ctx.log (String.format ("ENTITIES: (%d)", statistics.getEntityCount())); for (EntityKey ek : entityKeys) { Object obj = session.get(ek.getEntityName(), ek.getIdentifier()); LockMode lockMode = session.getCurrentLockMode(obj); ctx.log(String.format("[%s] %s %s", ek.getIdentifier(), ek.getEntityName(), lockMode)); } ctx.log ("==== COLLECTIONS ===="); Set<CollectionKey> collectionKeys = statistics.getCollectionKeys(); for (CollectionKey ck : collectionKeys) { ctx.log(String.format("[%s] %s", ck.getKey(), ck.getRole())); } ctx.log("====================="); return PREPARED | READONLY | NO_JOIN; }
@Override public void resolveInstance(RowProcessingState rowProcessingState) { final CollectionKey collectionKey = resolveCollectionKey( rowProcessingState ); final SharedSessionContractImplementor session = rowProcessingState.getSession(); final PersistenceContext persistenceContext = session.getPersistenceContext(); final PersistentCollectionDescriptor collectionDescriptor = getFetchedAttribute().getPersistentCollectionDescriptor(); // todo (6.0) : look for LoadingCollectionEntry? final PersistentCollection existing = persistenceContext.getCollection( collectionKey ); if ( existing != null ) { collectionInstance = existing; } else { collectionInstance = collectionDescriptor.instantiateWrapper( session, collectionKey.getKey() ); getParentAccess().registerResolutionListener( owner -> collectionInstance.setOwner( owner ) ); persistenceContext.addUninitializedCollection( collectionDescriptor, collectionInstance, collectionKey.getKey() ); final CollectionEntry collectionEntry = persistenceContext.getCollectionEntry( collectionInstance ); collectionEntry.setCurrentKey( collectionKey.getKey() ); if ( getCollectionDescriptor().getSemantics().getCollectionClassification() == CollectionClassification.ARRAY ) { session.getPersistenceContext().addCollectionHolder( collectionInstance ); } } }
"(%s) Beginning Initializer#resolveInstance for collection : %s", StringHelper.collapse( this.getClass().getName() ), LoggingHelper.toLoggableString( getNavigablePath(), collectionKey.getKey() ) ); "(%s) Found existing loading collection entry [%s]; using loading collection instance - %s", StringHelper.collapse( this.getClass().getName() ), LoggingHelper.toLoggableString( getNavigablePath(), collectionKey.getKey() ), LoggingHelper.toLoggableString( collectionInstance ) ); "(%s) Collection [%s] being loaded by another initializer [%s] - skipping processing", StringHelper.collapse( this.getClass().getName() ), LoggingHelper.toLoggableString( getNavigablePath(), collectionKey.getKey() ), existingLoadingEntry.getInitializer() ); "(%s) Found existing collection instance [%s] in Session; skipping processing - [%s]", StringHelper.collapse( this.getClass().getName() ), LoggingHelper.toLoggableString( getNavigablePath(), collectionKey.getKey() ), LoggingHelper.toLoggableString( collectionInstance ) ); "(%s) Found existing unowned collection instance [%s] in Session; skipping processing - [%s]", StringHelper.collapse( this.getClass().getName() ), LoggingHelper.toLoggableString( getNavigablePath(), collectionKey.getKey() ), LoggingHelper.toLoggableString( collectionInstance ) );
@Override public void resolveKey(RowProcessingState rowProcessingState) { keyContainerValue = keyTargetAssembler.assemble( rowProcessingState, rowProcessingState.getJdbcValuesSourceProcessingState().getProcessingOptions() ); if ( keyCollectionAssembler == null ) { keyCollectionValue = keyContainerValue; } else { keyCollectionValue = keyCollectionAssembler.assemble( rowProcessingState, rowProcessingState.getJdbcValuesSourceProcessingState().getProcessingOptions() ); } collectionKey = new CollectionKey( getFetchedAttribute().getPersistentCollectionDescriptor(), getKeyContainerValue() ); if ( CollectionLoadingLogger.DEBUG_ENABLED ) { CollectionLoadingLogger.INSTANCE.debugf( "(%s) Current row collection key : %s", StringHelper.collapse( this.getClass().getName() ), LoggingHelper.toLoggableString( getNavigablePath(), collectionKey.getKey() ) ); } }
for (CollectionKey ck : collectionKeys) info.addMessage(String.format("[%s] %s", ck.getKey(), ck.getRole()));