Package org.hibernate.mapping

Examples of org.hibernate.mapping.Collection


            determineSingularAssociationAttributeType( member )
        );
      }
            // collection
            if (value instanceof Collection) {
                final Collection collValue = (Collection)value;
                final Value elementValue = collValue.getElement();
                final org.hibernate.type.Type elementType = elementValue.getType();

                // First, determine the type of the elements and use that to help determine the
                // collection type)
                final Attribute.PersistentAttributeType elementPersistentAttributeType;
View Full Code Here


          configuration.setCacheConcurrencyStrategy( clazz.getEntityName(), getCacheConcurrencyStrategy() );
        }
      }
      itr = configuration.getCollectionMappings();
      while ( itr.hasNext() ) {
        Collection coll = (Collection) itr.next();
        configuration.setCollectionCacheConcurrencyStrategy( coll.getRole(), getCacheConcurrencyStrategy() );
      }
    }
  }
View Full Code Here

            determineSingularAssociationAttributeType( member )
        );
      }
            // collection
            if (value instanceof Collection) {
                final Collection collValue = (Collection)value;
                final Value elementValue = collValue.getElement();
                final org.hibernate.type.Type elementType = elementValue.getType();

                // First, determine the type of the elements and use that to help determine the
                // collection type)
                final Attribute.PersistentAttributeType elementPersistentAttributeType;
View Full Code Here

      }
    }

    iter = collections.values().iterator();
    while ( iter.hasNext() ) {
      Collection collection = (Collection) iter.next();

      if ( collection.isIdentified() ) {

        IdentifierGenerator ig = ( (IdentifierCollection) collection ).getIdentifier()
            .createIdentifierGenerator(
                dialect,
                defaultCatalog,
View Full Code Here

    return this;
  }

  public void setCollectionCacheConcurrencyStrategy(String collectionRole, String concurrencyStrategy, String region)
      throws MappingException {
    Collection collection = getCollectionMapping( collectionRole );
    if ( collection == null ) {
      throw new MappingException( "Cannot cache an unknown collection: " + collectionRole );
    }
    collection.setCacheConcurrencyStrategy( concurrencyStrategy );
    collection.setCacheRegionName( region );
  }
View Full Code Here

        ib.setValue( list.getIndex() );
        referenced.addProperty( ib );
      }
    }
    else {
      Collection coll = this.collection;
      throw new AnnotationException(
          "List/array has to be annotated with an @IndexColumn: "
              + coll.getRole()
      );
    }
  }
View Full Code Here

    Map tmpEntityToCollectionRoleMap = new HashMap();
    collectionPersisters = new HashMap();
    Iterator collections = cfg.getCollectionMappings();
    while ( collections.hasNext() ) {
      Collection model = (Collection) collections.next();
      final String cacheRegionName = cacheRegionPrefix + model.getCacheRegionName();
      final AccessType accessType = AccessType.parse( model.getCacheConcurrencyStrategy() );
      CollectionRegionAccessStrategy accessStrategy = null;
      if ( accessType != null && settings.isSecondLevelCacheEnabled() ) {
        log.trace( "Building cache for collection data [" + model.getRole() + "]" );
        CollectionRegion collectionRegion = settings.getRegionFactory().buildCollectionRegion( cacheRegionName, properties, CacheDataDescriptionImpl.decode( model ) );
        accessStrategy = collectionRegion.buildAccessStrategy( accessType );
        entityAccessStrategies.put( cacheRegionName, accessStrategy );
        allCacheRegions.put( cacheRegionName, collectionRegion );
      }
      CollectionPersister persister = PersisterFactory.createCollectionPersister( cfg, model, accessStrategy, this) ;
      collectionPersisters.put( model.getRole(), persister.getCollectionMetadata() );
      Type indexType = persister.getIndexType();
      if ( indexType != null && indexType.isAssociationType() && !indexType.isAnyType() ) {
        String entityName = ( ( AssociationType ) indexType ).getAssociatedEntityName( this );
        Set roles = ( Set ) tmpEntityToCollectionRoleMap.get( entityName );
        if ( roles == null ) {
View Full Code Here

      log.debug("Retrieving property {}.{}", associatedClass.getEntityName(), mappedByProperty);

      final Property property = associatedClass.getRecursiveProperty( columns[0].getMappedBy() );
      Iterator mappedByColumns;
      if ( property.getValue() instanceof Collection ) {
        Collection collection = ( (Collection) property.getValue() );
        Value element = collection.getElement();
        if ( element == null ) {
          throw new AnnotationException(
              "Illegal use of mappedBy on both sides of the relationship: "
                  + associatedClass.getEntityName() + "." + mappedByProperty
          );
        }
        mappedByColumns = element.getColumnIterator();
      }
      else {
        mappedByColumns = property.getValue().getColumnIterator();
      }
      while ( mappedByColumns.hasNext() ) {
        Column column = (Column) mappedByColumns.next();
        columns[0].overrideFromReferencedColumnIfNecessary( column );
        columns[0].linkValueUsingAColumnCopy( column, value );
      }
    }
    else if ( columns[0].isImplicit() ) {
      /**
       * if columns are implicit, then create the columns based on the
       * referenced entity id columns
       */
      Iterator idColumns;
      if ( referencedEntity instanceof JoinedSubclass ) {
        idColumns = ( (JoinedSubclass) referencedEntity ).getKey().getColumnIterator();
      }
      else {
        idColumns = referencedEntity.getIdentifier().getColumnIterator();
      }
      while ( idColumns.hasNext() ) {
        Column column = (Column) idColumns.next();
        columns[0].overrideFromReferencedColumnIfNecessary( column );
        columns[0].linkValueUsingDefaultColumnNaming( column, referencedEntity, value );
      }
    }
    else {
      int fkEnum = Ejb3JoinColumn.checkReferencedColumnsType( columns, referencedEntity, mappings );

      if ( Ejb3JoinColumn.NON_PK_REFERENCE == fkEnum ) {
        String referencedPropertyName;
        if ( value instanceof ToOne ) {
          referencedPropertyName = ( (ToOne) value ).getReferencedPropertyName();
        }
        else if ( value instanceof DependantValue ) {
          String propertyName = columns[0].getPropertyName();
          if ( propertyName != null ) {
            Collection collection = (Collection) referencedEntity.getRecursiveProperty( propertyName )
                .getValue();
            referencedPropertyName = collection.getReferencedPropertyName();
          }
          else {
            throw new AnnotationException( "SecondaryTable JoinColumn cannot reference a non primary key" );
          }

View Full Code Here

          configuration.setCacheConcurrencyStrategy( clazz.getEntityName(), getCacheConcurrencyStrategy() );
        }
      }
      itr = configuration.getCollectionMappings();
      while ( itr.hasNext() ) {
        Collection coll = (Collection) itr.next();
        configuration.setCollectionCacheConcurrencyStrategy( coll.getRole(), getCacheConcurrencyStrategy() );
      }
    }
  }
View Full Code Here

      }
    }

    iter = collections.values().iterator();
    while ( iter.hasNext() ) {
      Collection collection = (Collection) iter.next();

      if ( collection.isIdentified() ) {

        IdentifierGenerator ig = ( (IdentifierCollection) collection ).getIdentifier()
            .createIdentifierGenerator(
                dialect,
                defaultCatalog,
View Full Code Here

TOP

Related Classes of org.hibernate.mapping.Collection

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.