@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 ); } }
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" ); } }
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() ); }
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; }
protected Serializable findCollectionOwnerKey(ResultSetProcessingContextImpl context) { Object owner = context.getOwnerProcessingState( (Fetch) collectionReference ).getEntityInstance(); return collectionReference.getCollectionPersister().getCollectionType().getKeyOfOwner( owner, context.getSession() ); }
@Override public void endLoading(ResultSetProcessingContextImpl context) { context.getSession().getPersistenceContext() .getLoadContexts() .getCollectionLoadContext( context.getResultSet() ) .endLoadingCollections( collectionReference.getCollectionPersister() ); } }
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 );