private String extractDetails(CollectionReference collectionReference) { // todo : include some form of parameterized type signature? i.e., List<String>, Set<Person>, etc return String.format( "%s(collection=%s, querySpaceUid=%s, path=%s)", collectionReference.getClass().getSimpleName(), collectionReference.getCollectionPersister().getRole(), collectionReference.getQuerySpaceUid(), collectionReference.getPropertyPath().getFullPath() ); }
public CollectionFetchableIndexAnyGraph(CollectionReference collectionReference) { super( // this property path is just informational... collectionReference.getPropertyPath().append( "<index>" ) ); this.collectionReference = collectionReference; }
@Override public void add(CollectionReferenceInitializer collectionReferenceInitializer) { if ( collectionReferenceInitializer.getCollectionReference().getCollectionPersister().isArray() ) { if ( arrayReferenceInitializers == null ) { arrayReferenceInitializers = new ArrayList<CollectionReferenceInitializer>(); } arrayReferenceInitializers.add( collectionReferenceInitializer ); } else { if ( collectionReferenceInitializers == null ) { collectionReferenceInitializers = new ArrayList<CollectionReferenceInitializer>(); } collectionReferenceInitializers.add( collectionReferenceInitializer ); } }
int depth, PrintWriter printWriter) { final CollectionFetchableIndex indexGraph = collectionReference.getIndexGraph(); if ( indexGraph != null ) { printWriter.print( TreePrinterHelper.INSTANCE.generateNodePrefix( depth ) + "(collection index) " ); final CollectionFetchableElement elementGraph = collectionReference.getElementGraph(); if ( elementGraph != null ) { printWriter.print( TreePrinterHelper.INSTANCE.generateNodePrefix( depth ) + "(collection element) " );
@Override public void startingCollectionElements(CollectionElementDefinition elementDefinition) { final Type elementType = elementDefinition.getType(); log.tracef( "%s Starting collection element graph : %s", StringHelper.repeat( ">>", fetchSourceStack.size() ), elementDefinition.getCollectionDefinition().getCollectionPersister().getRole() ); final CollectionReference collectionReference = currentCollection(); final CollectionFetchableElement elementGraph = collectionReference.getElementGraph(); if ( elementType.isAssociationType() || elementType.isComponentType() ) { if ( elementGraph == null ) { throw new IllegalStateException( "CollectionReference did not return an expected element graph : " + elementDefinition.getCollectionDefinition().getCollectionPersister().getRole() ); } if ( !elementType.isAnyType() ) { pushToStack( (ExpandingFetchSource) elementGraph ); } } else { if ( elementGraph != null ) { throw new IllegalStateException( "CollectionReference returned an unexpected element graph : " + elementDefinition.getCollectionDefinition().getCollectionPersister().getRole() ); } } }
@Override public void startingCollectionIndex(CollectionIndexDefinition indexDefinition) { final Type indexType = indexDefinition.getType(); log.tracef( "%s Starting collection index graph : %s", StringHelper.repeat( ">>", fetchSourceStack.size() ), indexDefinition.getCollectionDefinition().getCollectionPersister().getRole() ); final CollectionReference collectionReference = currentCollection(); final CollectionFetchableIndex indexGraph = collectionReference.getIndexGraph(); if ( indexType.isEntityType() || indexType.isComponentType() ) { if ( indexGraph == null ) { throw new WalkingException( "CollectionReference did not return an expected index graph : " + indexDefinition.getCollectionDefinition().getCollectionPersister().getRole() ); } if ( !indexType.isAnyType() ) { pushToStack( (ExpandingFetchSource) indexGraph ); } } else { if ( indexGraph != null ) { throw new WalkingException( "CollectionReference returned an unexpected index graph : " + indexDefinition.getCollectionDefinition().getCollectionPersister().getRole() ); } } }
public CollectionFetchableElementCompositeGraph( CollectionReference collectionReference, ExpandingCompositeQuerySpace compositeQuerySpace) { super( compositeQuerySpace, false, // these property paths are just informational... collectionReference.getPropertyPath().append( "<element>" ) ); this.collectionReference = collectionReference; }
private void checkedPoppedCollection(CollectionReference poppedCollectionReference, CollectionDefinition collectionDefinition) { // make sure what we just poppedCollectionReference represents collectionDefinition. if ( ! poppedCollectionReference.getCollectionPersister().equals( collectionDefinition.getCollectionPersister() ) ) { throw new WalkingException( "Mismatched CollectionReference from stack on pop" ); } }
public CollectionFetchableElementEntityGraph( CollectionReference collectionReference, ExpandingEntityQuerySpace entityQuerySpace) { super( entityQuerySpace, collectionReference.getPropertyPath().append( "<elements>" ) ); this.collectionReference = collectionReference; }
protected Object findCollectionOwner( Serializable collectionRowKey, ResultSet resultSet, ResultSetProcessingContextImpl context) { final Object collectionOwner = context.getSession().getPersistenceContext().getCollectionOwner( collectionRowKey, collectionReference.getCollectionPersister() ); // todo : try org.hibernate.loader.plan.exec.process.spi.ResultSetProcessingContext.getOwnerProcessingState() ?? // -- specifically to return its ResultSetProcessingContext.EntityReferenceProcessingState#getEntityInstance() if ( collectionOwner == null ) { //TODO: This is assertion is disabled because there is a bug that means the // original owner of a transient, uninitialized collection is not known // if the collection is re-referenced by a different object associated // with the current Session //throw new AssertionFailure("bug loading unowned collection"); } return collectionOwner; }
public CollectionFetchableIndexCompositeGraph( CollectionReference collectionReference, ExpandingCompositeQuerySpace compositeQuerySpace) { super( compositeQuerySpace, false, collectionReference.getPropertyPath().append( "<index>" ) ); this.collectionReference = collectionReference; }
protected Serializable findCollectionOwnerKey(ResultSetProcessingContextImpl context) { Object owner = context.getOwnerProcessingState( (Fetch) collectionReference ).getEntityInstance(); return collectionReference.getCollectionPersister().getCollectionType().getKeyOfOwner( owner, context.getSession() ); }
public CollectionFetchableIndexEntityGraph( CollectionReference collectionReference, ExpandingEntityQuerySpace entityQuerySpace) { super( entityQuerySpace, collectionReference.getPropertyPath().append( "<index>" ) ); this.collectionReference = collectionReference; }
@Override public void endLoading(ResultSetProcessingContextImpl context) { context.getSession().getPersistenceContext() .getLoadContexts() .getCollectionLoadContext( context.getResultSet() ) .endLoadingCollections( collectionReference.getCollectionPersister() ); } }
public CollectionFetchableElementAnyGraph(CollectionReference collectionReference) { super( // this property path is just informational... collectionReference.getPropertyPath().append( "<element>" ) ); this.collectionReference = collectionReference; }
final Serializable collectionRowKey = (Serializable) collectionReference.getCollectionPersister().readKey( resultSet, aliases.getCollectionColumnAliases().getSuffixedKeyAliases(), "Found row of collection: %s", MessageHelper.collectionInfoString( collectionReference.getCollectionPersister(), collectionRowKey, context.getSession().getFactory() .getLoadingCollection( collectionReference.getCollectionPersister(), collectionRowKey ); collectionReference.getCollectionPersister(), aliases.getCollectionColumnAliases(), collectionOwner "Result set contains (possibly empty) collection: %s", MessageHelper.collectionInfoString( collectionReference.getCollectionPersister(), optionalKey, context.getSession().getFactory() .getLoadingCollection( collectionReference.getCollectionPersister(), optionalKey );
private void pushToCollectionStack(CollectionReference collectionReference) { log.trace( "Pushing collection reference to stack : " + collectionReference ); propertyPathStack.push( collectionReference.getPropertyPath() ); collectionReferenceStack.addFirst( collectionReference ); }