Package org.hibernate.metamodel.binding

Examples of org.hibernate.metamodel.binding.EntityBinding


    Map<String,ClassMetadata> classMeta = new HashMap<String,ClassMetadata>();
    for ( EntityBinding model : metadata.getEntityBindings() ) {
      // TODO: should temp table prep happen when metadata is being built?
      //model.prepareTemporaryTables( metadata, getDialect() );
      // cache region is defined by the root-class in the hierarchy...
      EntityBinding rootEntityBinding = metadata.getRootEntityBinding( model.getEntity().getName() );
      EntityRegionAccessStrategy accessStrategy = null;
      if ( settings.isSecondLevelCacheEnabled() &&
          rootEntityBinding.getHierarchyDetails().getCaching() != null &&
          model.getHierarchyDetails().getCaching() != null &&
          model.getHierarchyDetails().getCaching().getAccessType() != null ) {
        final String cacheRegionName = cacheRegionPrefix + rootEntityBinding.getHierarchyDetails().getCaching().getRegion();
        accessStrategy = EntityRegionAccessStrategy.class.cast( entityAccessStrategies.get( cacheRegionName ) );
        if ( accessStrategy == null ) {
          final AccessType accessType = model.getHierarchyDetails().getCaching().getAccessType();
          if ( LOG.isTraceEnabled() ) {
            LOG.tracev( "Building cache for entity data [{0}]", model.getEntity().getName() );
View Full Code Here


    Map<String,ClassMetadata> classMeta = new HashMap<String,ClassMetadata>();
    for ( EntityBinding model : metadata.getEntityBindings() ) {
      // TODO: should temp table prep happen when metadata is being built?
      //model.prepareTemporaryTables( metadata, getDialect() );
      // cache region is defined by the root-class in the hierarchy...
      EntityBinding rootEntityBinding = metadata.getRootEntityBinding( model.getEntity().getName() );
      EntityRegionAccessStrategy accessStrategy = null;
      if ( settings.isSecondLevelCacheEnabled() &&
          rootEntityBinding.getHierarchyDetails().getCaching() != null &&
          model.getHierarchyDetails().getCaching() != null &&
          model.getHierarchyDetails().getCaching().getAccessType() != null ) {
        final String cacheRegionName = cacheRegionPrefix + rootEntityBinding.getHierarchyDetails().getCaching().getRegion();
        accessStrategy = EntityRegionAccessStrategy.class.cast( entityAccessStrategies.get( cacheRegionName ) );
        if ( accessStrategy == null ) {
          final AccessType accessType = model.getHierarchyDetails().getCaching().getAccessType();
          if ( LOG.isTraceEnabled() ) {
            LOG.tracev( "Building cache for entity data [{0}]", model.getEntity().getName() );
View Full Code Here

   *
   * @param entityHierarchy THe hierarchy to process.
   */
  public void processEntityHierarchy(EntityHierarchy entityHierarchy) {
    currentInheritanceType = entityHierarchy.getHierarchyInheritanceType();
    EntityBinding rootEntityBinding = createEntityBinding( entityHierarchy.getRootEntitySource(), null );
    if ( currentInheritanceType != InheritanceType.NO_INHERITANCE ) {
      processHierarchySubEntities( entityHierarchy.getRootEntitySource(), rootEntityBinding );
    }
    currentHierarchyEntityMode = null;
  }
View Full Code Here

    currentHierarchyEntityMode = null;
  }

  private void processHierarchySubEntities(SubclassEntityContainer subclassEntitySource, EntityBinding superEntityBinding) {
    for ( SubclassEntitySource subEntity : subclassEntitySource.subclassEntitySources() ) {
      EntityBinding entityBinding = createEntityBinding( subEntity, superEntityBinding );
      processHierarchySubEntities( subEntity, entityBinding );
    }
  }
View Full Code Here

      return metadata.getEntityBinding( entitySource.getEntityName() );
    }

    currentBindingContext = entitySource.getLocalBindingContext();
    try {
      final EntityBinding entityBinding = doCreateEntityBinding( entitySource, superEntityBinding );

      metadata.addEntity( entityBinding );
      processedEntityNames.add( entityBinding.getEntity().getName() );

      processFetchProfiles( entitySource, entityBinding );

      return entityBinding;
    }
View Full Code Here

      currentBindingContext = null;
    }
  }

  private EntityBinding doCreateEntityBinding(EntitySource entitySource, EntityBinding superEntityBinding) {
    final EntityBinding entityBinding = createBasicEntityBinding( entitySource, superEntityBinding );

    bindSecondaryTables( entitySource, entityBinding );
    bindAttributes( entitySource, entityBinding );

    bindTableUniqueConstraints( entitySource, entityBinding );
View Full Code Here

  }

  private EntityBinding makeRootEntityBinding(RootEntitySource entitySource) {
    currentHierarchyEntityMode = entitySource.getEntityMode();

    final EntityBinding entityBinding = buildBasicEntityBinding( entitySource, null );

    bindPrimaryTable( entitySource, entityBinding );

    bindIdentifier( entitySource, entityBinding );
    bindVersion( entityBinding, entitySource );
    bindDiscriminator( entitySource, entityBinding );

    entityBinding.getHierarchyDetails().setCaching( entitySource.getCaching() );
    entityBinding.getHierarchyDetails().setExplicitPolymorphism( entitySource.isExplicitPolymorphism() );
    entityBinding.getHierarchyDetails().setOptimisticLockStyle( entitySource.getOptimisticLockStyle() );

    entityBinding.setMutable( entitySource.isMutable() );
    entityBinding.setWhereFilter( entitySource.getWhere() );
    entityBinding.setRowId( entitySource.getRowId() );

    return entityBinding;
  }
View Full Code Here

    return entityBinding;
  }

  private EntityBinding buildBasicEntityBinding(EntitySource entitySource, EntityBinding superEntityBinding) {
    final EntityBinding entityBinding = superEntityBinding == null
        ? new EntityBinding( currentInheritanceType, currentHierarchyEntityMode )
        : new EntityBinding( superEntityBinding );

    final String entityName = entitySource.getEntityName();
    final String className = currentHierarchyEntityMode == EntityMode.POJO ? entitySource.getClassName() : null;

    final Entity entity = new Entity(
        entityName,
        className,
        currentBindingContext.makeClassReference( className ),
        superEntityBinding == null ? null : superEntityBinding.getEntity()
    );
    entityBinding.setEntity( entity );

    entityBinding.setJpaEntityName( entitySource.getJpaEntityName() );

    if ( currentHierarchyEntityMode == EntityMode.POJO ) {
      final String proxy = entitySource.getProxy();
      if ( proxy != null ) {
        entityBinding.setProxyInterfaceType(
            currentBindingContext.makeClassReference(
                currentBindingContext.qualifyClassName( proxy )
            )
        );
        entityBinding.setLazy( true );
      }
      else if ( entitySource.isLazy() ) {
        entityBinding.setProxyInterfaceType( entityBinding.getEntity().getClassReferenceUnresolved() );
        entityBinding.setLazy( true );
      }
    }
    else {
      entityBinding.setProxyInterfaceType( null );
      entityBinding.setLazy( entitySource.isLazy() );
    }

    final String customTuplizerClassName = entitySource.getCustomTuplizerClassName();
    if ( customTuplizerClassName != null ) {
      entityBinding.setCustomEntityTuplizerClass(
          currentBindingContext.<EntityTuplizer>locateClassByName(
              customTuplizerClassName
          )
      );
    }

    final String customPersisterClassName = entitySource.getCustomPersisterClassName();
    if ( customPersisterClassName != null ) {
      entityBinding.setCustomEntityPersisterClass(
          currentBindingContext.<EntityPersister>locateClassByName(
              customPersisterClassName
          )
      );
    }

    entityBinding.setMetaAttributeContext( buildMetaAttributeContext( entitySource ) );

    entityBinding.setDynamicUpdate( entitySource.isDynamicUpdate() );
    entityBinding.setDynamicInsert( entitySource.isDynamicInsert() );
    entityBinding.setBatchSize( entitySource.getBatchSize() );
    entityBinding.setSelectBeforeUpdate( entitySource.isSelectBeforeUpdate() );
    entityBinding.setAbstract( entitySource.isAbstract() );

    entityBinding.setCustomLoaderName( entitySource.getCustomLoaderName() );
    entityBinding.setCustomInsert( entitySource.getCustomSqlInsert() );
    entityBinding.setCustomUpdate( entitySource.getCustomSqlUpdate() );
    entityBinding.setCustomDelete( entitySource.getCustomSqlDelete() );

    if ( entitySource.getSynchronizedTableNames() != null ) {
      entityBinding.addSynchronizedTableNames( entitySource.getSynchronizedTableNames() );
    }

    entityBinding.setJpaCallbackClasses(entitySource.getJpaCallbackClasses());

    return entityBinding;
  }
View Full Code Here

    return entityBinding;
  }

  private EntityBinding makeDiscriminatedSubclassBinding(SubclassEntitySource entitySource, EntityBinding superEntityBinding) {
    final EntityBinding entityBinding = buildBasicEntityBinding( entitySource, superEntityBinding );

    entityBinding.setPrimaryTable( superEntityBinding.getPrimaryTable() );
    entityBinding.setPrimaryTableName( superEntityBinding.getPrimaryTableName() );
    bindDiscriminatorValue( entitySource, entityBinding );

    return entityBinding;
  }
View Full Code Here

    return entityBinding;
  }

  private EntityBinding makeJoinedSubclassBinding(SubclassEntitySource entitySource, EntityBinding superEntityBinding) {
    final EntityBinding entityBinding = buildBasicEntityBinding( entitySource, superEntityBinding );

    bindPrimaryTable( entitySource, entityBinding );

    // todo : join
View Full Code Here

TOP

Related Classes of org.hibernate.metamodel.binding.EntityBinding

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.