Examples of AssociationType


Examples of org.hibernate.type.AssociationType

    while ( tokens.hasMoreTokens() ) {
      componentPath += tokens.nextToken();
      final Type type = provider.getType( componentPath );
      if ( type.isAssociationType() ) {
        // CollectionTypes are always also AssociationTypes - but there's not always an associated entity...
        final AssociationType atype = (AssociationType) type;
        final CollectionType ctype = type.isCollectionType() ? (CollectionType)type : null;
        final Type elementType = (ctype != null) ? ctype.getElementType( sessionFactory ) : null;
        // is the association a collection of components or value-types? (i.e a colloction of valued types?)
        if ( ctype != null  && elementType.isComponentType() ) {
          provider = new ComponentCollectionCriteriaInfoProvider( helper.getCollectionPersister(ctype.getRole()) );
        }
        else if ( ctype != null && !elementType.isEntityType() ) {
          provider = new ScalarCollectionCriteriaInfoProvider( helper, ctype.getRole() );
        }
        else {
          provider = new EntityCriteriaInfoProvider(
              (Queryable) sessionFactory.getEntityPersister( atype.getAssociatedEntityName( sessionFactory ) )
          );
        }
       
        componentPath = "";
      }
View Full Code Here

Examples of org.hibernate.type.AssociationType

      Type type = persister.getElementType();
      if ( type.isAssociationType() ) {
        // a many-to-many;
        // decrement currentDepth here to allow join across the association table
        // without exceeding MAX_FETCH_DEPTH (i.e. the "currentDepth - 1" bit)
        AssociationType associationType = (AssociationType) type;
        String[] aliasedLhsColumns = persister.getElementColumnNames(alias);
        String[] lhsColumns = persister.getElementColumnNames();
        // if the current depth is 0, the root thing being loaded is the
        // many-to-many collection itself.  Here, it is alright to use
        // an inner join...
View Full Code Here

Examples of org.hibernate.type.AssociationType

      final int currentDepth) throws MappingException {
    Type[] types = componentType.getSubtypes();
    String[] propertyNames = componentType.getPropertyNames();
    for ( int i = 0; i < types.length; i++ ) {
      if ( types[i].isAssociationType() ) {
        AssociationType associationType = (AssociationType) types[i];
        String[] aliasedLhsColumns = JoinHelper.getAliasedLHSColumnNames(
          associationType, alias, propertyNumber, begin, persister, getFactory()
        );
        String[] lhsColumns = JoinHelper.getLHSColumnNames(
          associationType, propertyNumber, begin, persister, getFactory()
View Full Code Here

Examples of org.hibernate.type.AssociationType

    for ( int i=0; i <types.length; i++ ) {
      int length = types[i].getColumnSpan( getFactory() );
      String[] lhsColumns = ArrayHelper.slice(cols, begin, length);

      if ( types[i].isAssociationType() ) {
        AssociationType associationType = (AssociationType) types[i];

        // simple, because we can't have a one-to-one or a collection
        // (or even a property-ref) in a composite-element:
        String[] aliasedLhsColumns = StringHelper.qualify(alias, lhsColumns);
View Full Code Here

Examples of org.hibernate.type.AssociationType

            final boolean nullable = propertyNullability == null || propertyNullability[subAttributeNumber];

            currentColumnPosition += columnSpan;

            if ( type.isAssociationType() ) {
              final AssociationType aType = (AssociationType) type;
              return new AssociationAttributeDefinition() {
                @Override
                public AssociationKey getAssociationKey() {
                  return new AssociationKey( lhsTableName, subAttributeLhsColumns );
                }


                @Override
                public AssociationNature getAssociationNature() {
                  if ( type.isAnyType() ) {
                    return AssociationNature.ANY;
                  }
                  else {
                    // cannot be a collection
                    return AssociationNature.ENTITY;
                  }
                }

                @Override
                public EntityDefinition toEntityDefinition() {
                  if ( getAssociationNature() != AssociationNature.ENTITY ) {
                    throw new WalkingException(
                        "Cannot build EntityDefinition from non-entity-typed attribute"
                    );
                  }
                  return (EntityPersister) aType.getAssociatedJoinable( ownerEntityPersister.getFactory() );
                }

                @Override
                public AnyMappingDefinition toAnyDefinition() {
                  if ( getAssociationNature() != AssociationNature.ANY ) {
View Full Code Here

Examples of org.hibernate.type.AssociationType

    if ( subgraphMap == null ) {
      subgraphMap = new HashMap<Class, Subgraph>();
    }

    final AssociationType attributeType = (AssociationType) Helper.resolveType( sessionFactory(), attribute );
    final Joinable joinable = attributeType.getAssociatedJoinable( sessionFactory() );

    if ( joinable.isCollection() ) {
      final EntityPersister elementEntityPersister = ( (QueryableCollection) joinable ).getElementPersister();
      if ( type == null ) {
        type = elementEntityPersister.getMappedClass();
View Full Code Here

Examples of org.hibernate.type.AssociationType

      throw new IllegalArgumentException(
          String.format( "Non-Map attribute [%s] cannot be target of key subgraph", getAttributeName() )
      );
    }

    final AssociationType attributeType = (AssociationType) Helper.resolveType( sessionFactory(), attribute );
    final QueryableCollection collectionPersister = (QueryableCollection) attributeType.getAssociatedJoinable( sessionFactory() );
    final Type indexType = collectionPersister.getIndexType();

    if ( ! indexType.isAssociationType() ) {
      throw new IllegalArgumentException(
          String.format( "Map index [%s] is not an entity; cannot be target of key subgraph", getAttributeName() )
      );
    }

    if ( keySubgraphMap == null ) {
      keySubgraphMap = new HashMap<Class, Subgraph>();
    }

    final AssociationType indexAssociationType = (AssociationType) indexType;
    final EntityPersister indexEntityPersister = (EntityPersister) indexAssociationType.getAssociatedJoinable( sessionFactory() );

    if ( type == null ) {
      type = indexEntityPersister.getMappedClass();
    }
    else {
View Full Code Here

Examples of org.hibernate.type.AssociationType

   */
  public int getSubclassPropertyTableNumber(String propertyPath) {
    String rootPropertyName = StringHelper.root(propertyPath);
    Type type = propertyMapping.toType(rootPropertyName);
    if ( type.isAssociationType() ) {
      AssociationType assocType = ( AssociationType ) type;
      if ( assocType.useLHSPrimaryKey() ) {
        // performance op to avoid the array search
        return 0;
      }
      else if ( type.isCollectionType() ) {
        // properly handle property-ref-based associations
        rootPropertyName = assocType.getLHSPropertyName();
      }
    }
    //Enable for HHH-440, which we don't like:
    /*if ( type.isComponentType() && !propertyName.equals(rootPropertyName) ) {
      String unrooted = StringHelper.unroot(propertyName);
View Full Code Here

Examples of org.hibernate.type.AssociationType

          " of: " + getEntityName()
        );
    }

    if ( type.isAssociationType() ) {
      AssociationType actype = (AssociationType) type;
      if ( actype.useLHSPrimaryKey() ) {
        columns = getIdentifierColumnNames();
        columnReaders = getIdentifierColumnReaders();
        columnReaderTemplates = getIdentifierColumnReaderTemplates();
      }
      else {
        String foreignKeyProperty = actype.getLHSPropertyName();
        if ( foreignKeyProperty!=null && !path.equals(foreignKeyProperty) ) {
          //TODO: this requires that the collection is defined after the
          //      referenced property in the mapping file (ok?)
          columns = (String[]) columnsByPropertyPath.get(foreignKeyProperty);
          if (columns==null) return; //get em on the second pass!
          columnReaders = (String[]) columnReadersByPropertyPath.get(foreignKeyProperty);
          columnReaderTemplates = (String[]) columnReaderTemplatesByPropertyPath.get(foreignKeyProperty);
        }
      }
    }

    if (path!=null) addPropertyPath(path, type, columns, columnReaders, columnReaderTemplates, formulaTemplates);

    if ( type.isComponentType() ) {
      CompositeType actype = (CompositeType) type;
      initComponentPropertyPaths( path, actype, columns, columnReaders, columnReaderTemplates, formulaTemplates, factory );
      if ( actype.isEmbedded() ) {
        initComponentPropertyPaths(
            path==null ? null : StringHelper.qualifier(path),
            actype,
            columns,
            columnReaders,
View Full Code Here

Examples of org.hibernate.type.AssociationType

      final Object anything,
      final boolean isCascadeDeleteEnabled) throws HibernateException {
   
    if ( child != null ) {
      if ( type.isAssociationType() ) {
        final AssociationType associationType = (AssociationType) type;
        if ( cascadeAssociationNow( associationType ) ) {
          cascadeAssociation(
              parent,
              child,
              type,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.