Package org.hibernate.type

Examples of org.hibernate.type.CollectionType


    }

    public EntityCollection getChildCollection(String name) throws LayerException {
      Type type = metadata.getPropertyType(name);
      if (type instanceof CollectionType) {
        CollectionType ct = (CollectionType) type;
        Collection coll = (Collection) metadata.getPropertyValue(object, name, EntityMode.POJO);
        if (coll == null) {
          // normally should not happen, hibernate instantiates it automatically
          coll = (Collection) ct.instantiate(0);
          metadata.setPropertyValue(object, name, coll, EntityMode.POJO);
        }
        String entityName = ct.getAssociatedEntityName((SessionFactoryImplementor) sessionFactory);
        ClassMetadata childMetadata = sessionFactory.getClassMetadata(entityName);
        return new HibernateEntityCollection(metadata, childMetadata, object, coll);
      } else {
        throw new LayerException(ExceptionCode.FEATURE_MODEL_PROBLEM);
      }
View Full Code Here


    if (propertyName.contains(SEPARATOR)) {
      String directProperty = propertyName.substring(0, propertyName.indexOf(SEPARATOR));
      try {
        Type prop = meta.getPropertyType(directProperty);
        if (prop.isCollectionType()) {
          CollectionType coll = (CollectionType) prop;
          prop = coll.getElementType((SessionFactoryImplementor) sessionFactory);
        }
        ClassMetadata propMeta = sessionFactory.getClassMetadata(prop.getReturnedClass());
        return getPropertyClass(propMeta, propertyName.substring(propertyName.indexOf(SEPARATOR) + 1));
      } catch (HibernateException e) {
        throw new HibernateLayerException(e, ExceptionCode.HIBERNATE_COULD_NOT_RESOLVE, propertyName,
View Full Code Here

    fromClause.addCollectionJoinFromElementByPath( path, destination );
//    origin.addDestination(destination);
    // Add the query spaces.
    fromClause.getWalker().addQuerySpaces( entityPersister.getQuerySpaces() );

    CollectionType type = queryableCollection.getCollectionType();
    String role = type.getRole();
    String roleAlias = origin.getTableAlias();

    String[] targetColumns = sfh.getCollectionElementColumns( role, roleAlias );
    AssociationType elementAssociationType = sfh.getElementAssociationType( type );
View Full Code Here

      return checkComponentNullability( value, (AbstractComponentType) propertyType );
    }
    else if ( propertyType.isCollectionType() ) {

      //persistent collections may have components
      CollectionType collectionType = (CollectionType) propertyType;
      Type collectionElementType = collectionType.getElementType( session.getFactory() );
      if ( collectionElementType.isComponentType() ) {
        //check for all components values in the collection

        AbstractComponentType componentType = (AbstractComponentType) collectionElementType;
        Iterator iter = CascadingAction.getLoadedElementsIterator(session, collectionType, value);
View Full Code Here

      return checkComponentNullability( value, (CompositeType) propertyType );
    }
    else if ( propertyType.isCollectionType() ) {

      //persistent collections may have components
      CollectionType collectionType = (CollectionType) propertyType;
      Type collectionElementType = collectionType.getElementType( session.getFactory() );
      if ( collectionElementType.isComponentType() ) {
        //check for all components values in the collection

        CompositeType componentType = (CompositeType) collectionElementType;
        Iterator iter = CascadingAction.getLoadedElementsIterator(session, collectionType, value);
View Full Code Here

   
    // If many-to-many, delete the FK row in the collection table.
    // This partially overlaps with DeleteExecutor, but it instead uses the temp table in the idSubselect.
    for ( Type type : targetedPersister.getPropertyTypes() ) {
      if ( type.isCollectionType() ) {
        CollectionType cType = (CollectionType) type;
        AbstractCollectionPersister cPersister = (AbstractCollectionPersister)factory.getCollectionPersister( cType.getRole() );
        if ( cPersister.isManyToMany() ) {
          deletes.add( generateDelete( cPersister.getTableName(),
              cPersister.getKeyColumnNames(), idSubselect, "bulk delete - m2m join table cleanup"));
        }
      }
View Full Code Here

      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 ) )
          );
View Full Code Here

  }

  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 );
View Full Code Here

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

                role,
                null
            );
          }
          else if ( propertyType.isCollectionType() ) {
            CollectionType collectionType = (CollectionType) propertyType;
            final String[] columns = origin.toColumns( originTableAlias, attributeName, false );

            final FromElementFactory fromElementFactory = new FromElementFactory(
                fromClause, origin,
                attributeName, classAlias, columns, false
            );
            final QueryableCollection queryableCollection = walker.getSessionFactoryHelper()
                .requireQueryableCollection( collectionType.getRole() );
            fromElement = fromElementFactory.createCollection(
                queryableCollection, collectionType.getRole(), JoinType.LEFT_OUTER_JOIN, true, false
            );
          }
        }

        if ( fromElement != null ) {
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.