org.hibernate.type.Type.isAnyType()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(10.7k)|赞(0)|评价(0)|浏览(105)

本文整理了Java中org.hibernate.type.Type.isAnyType()方法的一些代码示例,展示了Type.isAnyType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Type.isAnyType()方法的具体详情如下:
包路径:org.hibernate.type.Type
类名称:Type
方法名:isAnyType

Type.isAnyType介绍

[英]Return true if the implementation is castable to AnyType. Essentially a polymorphic version of (type instanceof AnyType.class).

An AnyType is additionally an AssociationType; so if this method returns true, #isAssociationType() should also return true.
[中]如果实现可强制转换为任何类型,则返回true。本质上是(AnyType.class的类型instanceof)的多态版本。
AnyType是AssociationType;因此,如果这个方法返回true,#isAssociationType()也应该返回true。

代码示例

代码示例来源:origin: hibernate/hibernate-orm

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() );
      }
    }
  }
}

代码示例来源:origin: hibernate/hibernate-orm

@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() );
}

代码示例来源:origin: hibernate/hibernate-orm

@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() );
  }
};

代码示例来源:origin: hibernate/hibernate-orm

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);
  }
}

代码示例来源:origin: hibernate/hibernate-orm

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
    );
  }
}

代码示例来源:origin: hibernate/hibernate-orm

@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()
  );
}

代码示例来源:origin: hibernate/hibernate-orm

final AssociationAttributeDefinition associationAttributeDefinition =
    (AssociationAttributeDefinition) attributeDefinition;
if ( attributeType.isAnyType() ) {

代码示例来源:origin: hibernate/hibernate-orm

@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()
  );
}

代码示例来源:origin: hibernate/hibernate-orm

if ( queryableCollection.getElementType().isAnyType() ) {

代码示例来源:origin: hibernate/hibernate-orm

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 );

代码示例来源:origin: hibernate/hibernate-orm

@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()
      );
    }
  }
}

代码示例来源:origin: hibernate/hibernate-orm

if ( elemType.isEntityType() || elemType.isAnyType() || elemType.isComponentType() ) {
  cascadeCollectionElements(
    action,

代码示例来源:origin: hibernate/hibernate-orm

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 );
  }
}

代码示例来源:origin: hibernate/hibernate-orm

else if ( type.isAnyType() ) {
  return isNullifiable( null, value ) ? null : value;

代码示例来源:origin: hibernate/hibernate-orm

else if ( type.isAnyType() ) {
  if ( !isNullable && nullifier.isNullifiable( null, value ) ) {
    nonNullableTransientEntities.add( propertyName, value );

代码示例来源:origin: hibernate/hibernate-orm

@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()
      );
    }
  }
}

代码示例来源:origin: hibernate/hibernate-orm

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 );
  }
}

代码示例来源:origin: hibernate/hibernate-orm

return new CollectionFetchableElementEntityGraph( this, entityQuerySpace );
else if ( type.isAnyType() ) {
  return new CollectionFetchableElementAnyGraph( this );

代码示例来源:origin: hibernate/hibernate-orm

return new CollectionFetchableIndexEntityGraph( this, entityQuerySpace );
else if ( type.isAnyType() ) {
  return new CollectionFetchableIndexAnyGraph( this );

代码示例来源:origin: hibernate/hibernate-orm

if ( dot.getDataType().isAnyType() ) {
  throw new SemanticException( "An AnyType attribute cannot be join fetched" );

相关文章