Package org.hibernate.metamodel.binding

Examples of org.hibernate.metamodel.binding.EntityBinding


      for ( EntityClass entityClass : hierarchy ) {
        // for classes annotated w/ @Entity we create a EntityBinding
        if ( ConfiguredClassType.ENTITY.equals( entityClass.getConfiguredClassType() ) ) {
          LOG.bindingEntityFromAnnotatedClass( entityClass.getName() );
          EntityBinder entityBinder = new EntityBinder( metadata, entityClass, parent );
          EntityBinding binding = entityBinder.bind();
          parent = binding.getEntity();
        }
        // for classes annotated w/ @MappedSuperclass we just create the domain instance
        // the attribute bindings will be part of the first entity subclass
        else if ( ConfiguredClassType.MAPPED_SUPERCLASS.equals( entityClass.getConfiguredClassType() ) ) {
          parent = new Superclass( entityClass.getName(), parent );
View Full Code Here


    String entityName = getBindingContext().extractEntityName( xmlClazz );
    if ( entityName == null ) {
      throw new MappingException( "Unable to determine entity name" );
    }

    EntityBinding entityBinding = new EntityBinding();
    basicEntityBinding( xmlClazz, entityBinding, null );
    basicTableBinding( xmlClazz, entityBinding );

    bindIdentifier( xmlClazz, entityBinding );
    bindDiscriminator( xmlClazz, entityBinding );
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.getCaching() != null &&
          model.getCaching() != null &&
          model.getCaching().getAccessType() != null ) {
        final String cacheRegionName = cacheRegionPrefix + rootEntityBinding.getCaching().getRegion();
        accessStrategy = EntityRegionAccessStrategy.class.cast( entityAccessStrategies.get( cacheRegionName ) );
        if ( accessStrategy == null ) {
          final AccessType accessType = model.getCaching().getAccessType();
          LOG.trace("Building cache for entity data [" + model.getEntity().getName() + "]");
          EntityRegion entityRegion =
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();
          LOG.trace("Building cache for entity data [" + model.getEntity().getName() + "]");
          EntityRegion entityRegion = settings.getRegionFactory().buildEntityRegion(
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.getBindingContext();
    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.setMutable( entitySource.isMutable() );
    entityBinding.setExplicitPolymorphism( entitySource.isExplicitPolymorphism() );
    entityBinding.setWhereFilter( entitySource.getWhere() );
    entityBinding.setRowId( entitySource.getRowId() );
    entityBinding.setOptimisticLockStyle( entitySource.getOptimisticLockStyle() );
    entityBinding.setCaching( entitySource.getCaching() );

    return entityBinding;
  }
View Full Code Here

    return entityBinding;
  }


  private EntityBinding buildBasicEntityBinding(EntitySource entitySource, EntityBinding superEntityBinding) {
    final EntityBinding entityBinding = new EntityBinding();
    entityBinding.setSuperEntityBinding( superEntityBinding );
    entityBinding.setInheritanceType( currentInheritanceType );

    entityBinding.setEntityMode( currentHierarchyEntityMode );

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

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

    entityBinding.setJpaEntityName( entitySource.getJpaEntityName() );

    if ( entityBinding.getEntityMode() == 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() );
    }

    return entityBinding;
  }
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.