Package org.hibernate.type

Examples of org.hibernate.type.CollectionType


    }

    FromReferenceNode mapReference = getMapReference();
    mapReference.resolve( true, true );
    if ( mapReference.getDataType().isCollectionType() ) {
      CollectionType collectionType = (CollectionType) mapReference.getDataType();
      if ( Map.class.isAssignableFrom( collectionType.getReturnedClass() ) ) {
        FromElement sourceFromElement = mapReference.getFromElement();
        setFromElement( sourceFromElement );
        setDataType( resolveType( sourceFromElement.getQueryableCollection() ) );
        this.columns = resolveColumns( sourceFromElement.getQueryableCollection() );
        initText( this.columns );
View Full Code Here


    if (!getDataType().isCollectionType()) {
      throw new SemanticException("Collection expected; [" + propertyName + "] does not refer to a collection property");
    }

    // TODO : most of below was taken verbatim from DotNode; should either delegate this logic or super-type it
    CollectionType type = (CollectionType) getDataType();
    String role = type.getRole();
    QueryableCollection queryableCollection = getSessionFactoryHelper().requireQueryableCollection(role);

    String alias = null// DotNode uses null here...
    String columnTableAlias = getFromElement().getTableAlias();
    JoinType joinType = JoinType.INNER_JOIN;
View Full Code Here

      componentPath += tokens.nextToken();
      Type type = provider.getType( componentPath );
      if ( type.isAssociationType() ) {
        // CollectionTypes are always also AssociationTypes - but there's not always an associated entity...
        AssociationType atype = ( AssociationType ) type;
        CollectionType ctype = type.isCollectionType() ? (CollectionType)type : null;
        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 )
                        ));
View Full Code Here

        return null;
      }
      return getEntity( session.generateEntityKey( owenerId, ownerPersister ) );
    }

    final CollectionType collectionType = collectionPersister.getCollectionType();

    //    2) The incoming key is most likely the collection key which we need to resolve to the owner key
    //      find the corresponding owner instance
    //      a) try by EntityUniqueKey
    if ( collectionType.getLHSPropertyName() != null ) {
      final Object owner = getEntity(
          new EntityUniqueKey(
              ownerPersister.getEntityName(),
              collectionType.getLHSPropertyName(),
              key,
              collectionPersister.getKeyType(),
              ownerPersister.getEntityMode(),
              session.getFactory()
          )
      );
      if ( owner != null ) {
        return owner;
      }

      //    b) try by EntityKey, which means we need to resolve owner-key -> collection-key
      //      IMPL NOTE : yes if we get here this impl is very non-performant, but PersistenceContext
      //          was never designed to handle this case; adding that capability for real means splitting
      //          the notions of:
      //            1) collection key
      //            2) collection owner key
      //           these 2 are not always the same (same is true in the case of ToOne associations with
      //           property-ref).  That would require changes to (at least) CollectionEntry and quite
      //          probably changes to how the sql for collection initializers are generated
      //
      //      We could also possibly see if the referenced property is a natural id since we already have caching
      //      in place of natural id snapshots.  BUt really its better to just do it the right way ^^ if we start
      //       going that route
      final Serializable ownerId = ownerPersister.getIdByUniqueKey( key, collectionType.getLHSPropertyName(), session );
      return getEntity( session.generateEntityKey( ownerId, ownerPersister ) );
    }

    // as a last resort this is what the old code did...
    return getEntity( session.generateEntityKey( key, collectionPersister.getOwnerEntityPersister() ) );
View Full Code Here

      LoadPlanBuildingContext loadPlanBuildingContext) {

    // general question here wrt Joins and collection fetches...  do we create multiple Joins for many-to-many,
    // for example, or do we allow the Collection QuerySpace to handle that?

    final CollectionType fetchedType = (CollectionType) attributeDefinition.getType();
    final CollectionPersister fetchedPersister = loadPlanBuildingContext.getSessionFactory().getCollectionPersister(
        fetchedType.getRole()
    );

    if ( fetchedPersister == null ) {
      throw new WalkingException(
          String.format(
              "Unable to locate CollectionPersister [%s] for fetch [%s]",
              fetchedType.getRole(),
              attributeDefinition.getName()
          )
      );
    }
    final Join join = querySpace.addCollectionJoin(
View Full Code Here

    }

    final SessionFactoryImplementor sessionFactory = ((SessionImplementor) session).getFactory();
    final Type propertyType = sessionFactory.getEntityPersister( entityName ).getPropertyType( propertyName );
    if ( propertyType.isCollectionType() ) {
      CollectionType collectionPropertyType = (CollectionType) propertyType;
      // Handling collection of components.
      if ( collectionPropertyType.getElementType( sessionFactory ) instanceof ComponentType ) {
        // Adding restrictions to compare data outside of primary key.
        for ( Map.Entry<String, Object> dataEntry : persistentCollectionChangeData.getData().entrySet() ) {
          if ( !originalIdPropName.equals( dataEntry.getKey() ) ) {
            qb.getRootParameters().addWhereWithParam( dataEntry.getKey(), true, "=", dataEntry.getValue() );
          }
View Full Code Here

        // owners we are about to delete.  "collection table" is
        // (unfortunately) indicated in a number of ways, but here we
        // are mainly concerned with:
        //    1) many-to-many mappings
        //    2) basic collection mappings
        final CollectionType cType = (CollectionType) type;
        final AbstractCollectionPersister cPersister = (AbstractCollectionPersister) factory
              .getCollectionPersister( cType.getRole() );
        final boolean hasCollectionTable = cPersister.isManyToMany()
            || !cPersister.getElementType().isAssociationType();
        if ( !hasCollectionTable ) {
          continue;
        }
View Full Code Here

      componentPath += tokens.nextToken();
      Type type = provider.getType( componentPath );
      if ( type.isAssociationType() ) {
        // CollectionTypes are always also AssociationTypes - but there's not always an associated entity...
        AssociationType atype = ( AssociationType ) type;
        CollectionType ctype = type.isCollectionType() ? (CollectionType)type : null;
        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 )
                        ));
View Full Code Here

        sourceFromElement = mapReference.getFromElement();
      }
    }
    else {
      if ( mapReference.getDataType().isCollectionType() ) {
        CollectionType collectionType = (CollectionType) mapReference.getDataType();
        if ( Map.class.isAssignableFrom( collectionType.getReturnedClass() ) ) {
          sourceFromElement = mapReference.getFromElement();
        }
      }
    }
View Full Code Here

    if (!getDataType().isCollectionType()) {
      throw new SemanticException("Collection expected; [" + propertyName + "] does not refer to a collection property");
    }

    // TODO : most of below was taken verbatim from DotNode; should either delegate this logic or super-type it
    CollectionType type = (CollectionType) getDataType();
    String role = type.getRole();
    QueryableCollection queryableCollection = getSessionFactoryHelper().requireQueryableCollection(role);

    String alias = null// DotNode uses null here...
    String columnTableAlias = getFromElement().getTableAlias();
    JoinType joinType = JoinType.INNER_JOIN;
View Full Code Here

TOP

Related Classes of org.hibernate.type.CollectionType

Copyright © 2018 www.massapicom. 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.