Package org.hibernate.mapping

Examples of org.hibernate.mapping.Collection


    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


    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

            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

        .qualify( path, propertyName );

      CollectionType collectType = CollectionType.collectionTypeFromString( name );
      Value value = null;
      if ( collectType != null ) {
        Collection collection = collectType.create(
            subnode,
            subpath,
            component.getOwner(),
            mappings, inheritedMetas
          );
View Full Code Here

      String propertyName = subnode.attributeValue( "name" );

      CollectionType collectType = CollectionType.collectionTypeFromString( name );
      Value value = null;
      if ( collectType != null ) {
        Collection collection = collectType.create(
            subnode,
            StringHelper.qualify( entityName, propertyName ),
            persistentClass,
            mappings, inheritedMetas
          );
View Full Code Here

        mappings.addUniquePropertyReference( toOne.getReferencedEntityName(), propertyRef );
      }
      toOne.setCascadeDeleteEnabled( "cascade".equals( subnode.attributeValue( "on-delete" ) ) );
    }
    else if ( value instanceof Collection ) {
      Collection coll = (Collection) value;
      String propertyRef = coll.getReferencedPropertyName();
      // not necessarily a *unique* property reference
      if ( propertyRef != null ) {
        mappings.addPropertyReference( coll.getOwnerEntityName(), propertyRef );
      }
    }

    value.createForeignKey();
    Property prop = new Property();
View Full Code Here

          }
        }

        iter = cfg.getCollectionMappings();
        while ( iter.hasNext() ) {
          Collection coll = (Collection) iter.next();
          cfg.setCollectionCacheConcurrencyStrategy(
              coll.getRole(),
              getCacheConcurrencyStrategy()
          );
        }

      }
View Full Code Here

    Map<String,Set<String>> tmpEntityToCollectionRoleMap = new HashMap<String,Set<String>>();
    collectionPersisters = new HashMap<String,CollectionPersister>();
    Map<String,CollectionMetadata> tmpCollectionMetadata = new HashMap<String,CollectionMetadata>();
    Iterator collections = cfg.getCollectionMappings();
    while ( collections.hasNext() ) {
      Collection model = (Collection) collections.next();
      final String cacheRegionName = cacheRegionPrefix + model.getCacheRegionName();
      final AccessType accessType = AccessType.fromExternalName( model.getCacheConcurrencyStrategy() );
      CollectionRegionAccessStrategy accessStrategy = null;
      if ( accessType != null && settings.isSecondLevelCacheEnabled() ) {
        LOG.tracev( "Building shared cache region for collection data [{0}]", model.getRole() );
        CollectionRegion collectionRegion = regionFactory.buildCollectionRegion( cacheRegionName, properties, CacheDataDescriptionImpl
            .decode( model ) );
        accessStrategy = collectionRegion.buildAccessStrategy( accessType );
        entityAccessStrategies.put( cacheRegionName, accessStrategy );
        cacheAccess.addCacheRegion( cacheRegionName, collectionRegion );
      }
      CollectionPersister persister = persisterFactory.createCollectionPersister(
          cfg,
          model,
          accessStrategy,
          this
      ) ;
      collectionPersisters.put( model.getRole(), persister );
      tmpCollectionMetadata.put( model.getRole(), persister.getCollectionMetadata() );
      Type indexType = persister.getIndexType();
      if ( indexType != null && indexType.isAssociationType() && !indexType.isAnyType() ) {
        String entityName = ( ( AssociationType ) indexType ).getAssociatedEntityName( this );
        Set roles = tmpEntityToCollectionRoleMap.get( entityName );
        if ( roles == null ) {
View Full Code Here

  public void setCollectionCacheConcurrencyStrategy(String collectionRole, String concurrencyStrategy, String region) {
    caches.add( new CacheHolder( collectionRole, concurrencyStrategy, region, false, false ) );
  }

  private void applyCollectionCacheConcurrencyStrategy(CacheHolder holder) {
    Collection collection = getCollectionMapping( holder.role );
    if ( collection == null ) {
      throw new MappingException( "Cannot cache an unknown collection: " + holder.role );
    }
    collection.setCacheConcurrencyStrategy( holder.usage );
    collection.setCacheRegionName( holder.region );
  }
View Full Code Here

  public void setCollectionCacheConcurrencyStrategy(String collectionRole, String concurrencyStrategy, String region) {
    caches.add( new CacheHolder( collectionRole, concurrencyStrategy, region, false, false ) );
  }

  private void applyCollectionCacheConcurrencyStrategy(CacheHolder holder) {
    Collection collection = getCollectionMapping( holder.role );
    if ( collection == null ) {
      throw new MappingException( "Cannot cache an unknown collection: " + holder.role );
    }
    collection.setCacheConcurrencyStrategy( holder.usage );
    collection.setCacheRegionName( holder.region );
  }
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.