Package org.hibernate.metamodel.binding

Examples of org.hibernate.metamodel.binding.EntityBinding


  }

  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

    return entityBinding;
  }

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

    bindPrimaryTable( entitySource, entityBinding );

    // todo : ??
View Full Code Here

      }
      pluralAttributeBinding.setCollectionTable( collectionTable );
    }
    else {
      // todo : not sure wel have all the needed info here in all cases, specifically when needing to know the "other side"
      final EntityBinding owner = pluralAttributeBinding.getContainer().seekEntityBinding();
      final String ownerTableLogicalName = Table.class.isInstance( owner.getPrimaryTable() )
          ? Table.class.cast( owner.getPrimaryTable() ).getTableName().getName()
          : null;
      String collectionTableName = currentBindingContext.getNamingStrategy().collectionTableName(
          owner.getEntity().getName(),
          ownerTableLogicalName,
          null,  // todo : here
          null,  // todo : and here
          pluralAttributeBinding.getContainer().getPathBase() + '.' + attributeSource.getName()
      );
View Full Code Here

    this.classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
  }

  @Override
  public void processCallbacksForEntity(Object entityObject, CallbackRegistryImpl callbackRegistry) {
    final EntityBinding entityBinding = (EntityBinding) entityObject;
    final String entityClassName = entityBinding.getEntity().getClassName();
    if ( entityClassName == null ) {
      return;
    }

    try {
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 ( traceEnabled ) {
            LOG.tracev( "Building cache for entity data [{0}]", model.getEntity().getName() );
View Full Code Here

    this.classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
  }

  @Override
  public void processCallbacksForEntity(Object entityObject, CallbackRegistryImpl callbackRegistry) {
    final EntityBinding entityBinding = (EntityBinding) entityObject;
    final String entityClassName = entityBinding.getEntity().getClassName();
    if ( entityClassName == null ) {
      return;
    }

    try {
View Full Code Here

    return entityBindingMap.get( entityName );
  }

  @Override
  public EntityBinding getRootEntityBinding(String entityName) {
    EntityBinding binding = entityBindingMap.get( entityName );
    if ( binding == null ) {
      throw new IllegalStateException( "Unknown entity binding: " + entityName );
    }

    do {
      if ( binding.isRoot() ) {
        return binding;
      }
      binding = binding.getSuperEntityBinding();
    } while ( binding != null );

    throw new AssertionFailure( "Entity binding has no root: " + entityName );
  }
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.