public void collectQuerySpaces(Collection<String> spaces) { for ( EntityPersister persister : alias2Persister.values() ) { Collections.addAll( spaces, (String[]) persister.getQuerySpaces() ); } for ( CollectionPersister persister : alias2CollectionPersister.values() ) { final Type elementType = persister.getElementType(); if ( elementType.isEntityType() && ! elementType.isAnyType() ) { final Joinable joinable = ( (EntityType) elementType ).getAssociatedJoinable( factory ); Collections.addAll( spaces, (String[]) ( (EntityPersister) joinable ).getQuerySpaces() ); } } } }
@Override public AnyMappingDefinition toAnyMappingDefinition() { final Type type = getType(); if ( ! type.isAnyType() ) { throw new IllegalStateException( "Cannot treat collection element type as ManyToAny" ); } return new StandardAnyTypeDefinition( (AnyType) type, isLazy() || isExtraLazy() ); }
@Override public AnyMappingDefinition toAnyMappingDefinition() { final Type type = getType(); if ( ! type.isAnyType() ) { throw new IllegalStateException( "Cannot treat collection index type as ManyToAny" ); } return new StandardAnyTypeDefinition( (AnyType) type, isLazy() || isExtraLazy() ); } };
private void addAssociationsToTheSetForOneProperty(String name, Type type, String prefix, SessionFactoryImplementor factory) { if ( type.isCollectionType() ) { CollectionType collType = (CollectionType) type; Type assocType = collType.getElementType( factory ); addAssociationsToTheSetForOneProperty(name, assocType, prefix, factory); } //ToOne association else if ( type.isEntityType() || type.isAnyType() ) { associations.add( prefix + name ); } else if ( type.isComponentType() ) { CompositeType componentType = (CompositeType) type; addAssociationsToTheSetForAllProperties( componentType.getPropertyNames(), componentType.getSubtypes(), (prefix.equals( "" ) ? name : prefix + name) + ".", factory); } }
private static void cascadeAssociation( final CascadingAction action, final CascadePoint cascadePoint, final EventSource eventSource, final int componentPathStackDepth, final Object parent, final Object child, final Type type, final CascadeStyle style, final Object anything, final boolean isCascadeDeleteEnabled) { if ( type.isEntityType() || type.isAnyType() ) { cascadeToOne( action, eventSource, parent, child, type, style, anything, isCascadeDeleteEnabled ); } else if ( type.isCollectionType() ) { cascadeCollection( action, cascadePoint, eventSource, componentPathStackDepth, parent, child, style, anything, (CollectionType) type ); } }
@Override public void finishingCollectionElements(CollectionElementDefinition elementDefinition) { final Type elementType = elementDefinition.getType(); if ( elementType.isAnyType() ) { // nothing to do because the element graph was not pushed in #startingCollectionElement.. } else if ( elementType.isComponentType() || elementType.isAssociationType()) { // pop it from the stack final ExpandingFetchSource popped = popFromStack(); // validation if ( ! CollectionFetchableElement.class.isInstance( popped ) ) { throw new WalkingException( "Mismatched FetchSource from stack on pop" ); } } log.tracef( "%s Finished collection element graph : %s", StringHelper.repeat( "<<", fetchSourceStack.size() ), elementDefinition.getCollectionDefinition().getCollectionPersister().getRole() ); }
final AssociationAttributeDefinition associationAttributeDefinition = (AssociationAttributeDefinition) attributeDefinition; if ( attributeType.isAnyType() ) {
@Override public void finishingCollectionIndex(CollectionIndexDefinition indexDefinition) { final Type indexType = indexDefinition.getType(); if ( indexType.isAnyType() ) { // nothing to do because the index graph was not pushed in #startingCollectionIndex. } else if ( indexType.isEntityType() || indexType.isComponentType() ) { // todo : validate the stack? final ExpandingFetchSource fetchSource = popFromStack(); if ( !CollectionFetchableIndex.class.isInstance( fetchSource ) ) { throw new WalkingException( "CollectionReference did not return an expected index graph : " + indexDefinition.getCollectionDefinition().getCollectionPersister().getRole() ); } } log.tracef( "%s Finished collection index graph : %s", StringHelper.repeat( "<<", fetchSourceStack.size() ), indexDefinition.getCollectionDefinition().getCollectionPersister().getRole() ); }
if ( queryableCollection.getElementType().isAnyType() ) {
collectionPersisterMap.put( model.getRole(), persister ); Type indexType = persister.getIndexType(); if ( indexType != null && indexType.isAssociationType() && !indexType.isAnyType() ) { String entityName = ( (AssociationType) indexType ).getAssociatedEntityName( sessionFactory ); Set<String> roles = collectionRolesByEntityParticipant.get( entityName ); if ( elementType.isAssociationType() && !elementType.isAnyType() ) { String entityName = ( ( AssociationType ) elementType ).getAssociatedEntityName( sessionFactory ); Set<String> roles = collectionRolesByEntityParticipant.get( entityName );
@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() ); } } }
if ( elemType.isEntityType() || elemType.isAnyType() || elemType.isComponentType() ) { cascadeCollectionElements( action,
private void visitCollectionIndex(CollectionDefinition collectionDefinition) { final CollectionIndexDefinition collectionIndexDefinition = collectionDefinition.getIndexDefinition(); if ( collectionIndexDefinition == null ) { return; } strategy.startingCollectionIndex( collectionIndexDefinition ); try { log.debug( "Visiting index for collection : " + currentPropertyPath.getFullPath() ); currentPropertyPath = currentPropertyPath.append( "<index>" ); try { final Type collectionIndexType = collectionIndexDefinition.getType(); if ( collectionIndexType.isAnyType() ) { visitAnyDefinition( collectionIndexDefinition.toAnyMappingDefinition() ); } else if ( collectionIndexType.isComponentType() ) { visitCompositeDefinition( collectionIndexDefinition.toCompositeDefinition() ); } else if ( collectionIndexType.isAssociationType() ) { visitEntityDefinition( collectionIndexDefinition.toEntityDefinition() ); } } finally { currentPropertyPath = currentPropertyPath.getParent(); } } finally { strategy.finishingCollectionIndex( collectionIndexDefinition ); } }
else if ( type.isAnyType() ) { return isNullifiable( null, value ) ? null : value;
else if ( type.isAnyType() ) { if ( !isNullable && nullifier.isNullifiable( null, value ) ) { nonNullableTransientEntities.add( propertyName, value );
@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() ); } } }
private void visitCollectionElements(CollectionDefinition collectionDefinition) { final CollectionElementDefinition elementDefinition = collectionDefinition.getElementDefinition(); strategy.startingCollectionElements( elementDefinition ); try { final Type collectionElementType = elementDefinition.getType(); if ( collectionElementType.isAnyType() ) { visitAnyDefinition( elementDefinition.toAnyMappingDefinition() ); } else if ( collectionElementType.isComponentType() ) { visitCompositeDefinition( elementDefinition.toCompositeElementDefinition() ); } else if ( collectionElementType.isEntityType() ) { if ( !collectionDefinition.getCollectionPersister().isOneToMany() ) { final QueryableCollection queryableCollection = (QueryableCollection) collectionDefinition.getCollectionPersister(); addAssociationKey( new AssociationKey( queryableCollection.getTableName(), queryableCollection.getElementColumnNames() ) ); } visitEntityDefinition( elementDefinition.toEntityDefinition() ); } } finally { strategy.finishingCollectionElements( elementDefinition ); } }
return new CollectionFetchableElementEntityGraph( this, entityQuerySpace ); else if ( type.isAnyType() ) { return new CollectionFetchableElementAnyGraph( this );
return new CollectionFetchableIndexEntityGraph( this, entityQuerySpace ); else if ( type.isAnyType() ) { return new CollectionFetchableIndexAnyGraph( this );
if ( dot.getDataType().isAnyType() ) { throw new SemanticException( "An AnyType attribute cannot be join fetched" );