Package org.hibernate.metamodel.binding

Examples of org.hibernate.metamodel.binding.EntityBinding


    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


    this.configuredClass = configuredClass;
    this.meta = metadata;
  }

  public void bind() {
    EntityBinding entityBinding = new EntityBinding();
    EntityBindingStateImpl entityBindingState = new EntityBindingStateImpl( getSuperType(), configuredClass );

    bindJpaEntityAnnotation( entityBindingState );
    bindHibernateEntityAnnotation( entityBindingState ); // optional hibernate specific @org.hibernate.annotations.Entity

    schemaName = createSchemaName();
    bindTable( entityBinding );

    // bind entity level annotations
    bindWhereFilter( entityBindingState );
    bindJpaCaching( entityBindingState );
    bindHibernateCaching( entityBindingState );
    bindProxy( entityBindingState );
    bindSynchronize( entityBindingState );
    bindCustomSQL( entityBindingState );
    bindRowId( entityBindingState );
    bindBatchSize( entityBindingState );

    entityBinding.initialize( meta, entityBindingState );

    bindInheritance( entityBinding );

    // take care of the id, attributes and relations
    if ( configuredClass.isRoot() ) {
View Full Code Here

    ConfiguredClass parent = configuredClass.getParent();
    if ( parent == null ) {
      return null;
    }

    EntityBinding parentBinding = meta.getEntityBinding( parent.getName() );
    if ( parentBinding == null ) {
      throw new AssertionFailure(
          "Parent entity " + parent.getName() + " of entity " + configuredClass.getName() + " not yet created!"
      );
    }

    return parentBinding.getEntity();
  }
View Full Code Here

    return entityBindingMap.get( entityName );
  }

  @Override
  public EntityBinding getRootEntityBinding(String entityName) {
    EntityBinding rootEntityBinding = rootEntityBindingMap.get( entityName );
    if ( rootEntityBinding == null ) {
      EntityBinding entityBinding = entityBindingMap.get( entityName );
      if ( entityBinding == null ) {
        throw new IllegalStateException( "Unknown entity binding: " + entityName );
      }
      if ( entityBinding.isRoot() ) {
        rootEntityBinding = entityBinding;
      }
      else {
        if ( entityBinding.getEntity().getSuperType() == null ) {
          throw new IllegalStateException( "Entity binding has no root: " + entityName );
        }
        rootEntityBinding = getRootEntityBinding( entityBinding.getEntity().getSuperType().getName() );
      }
      rootEntityBindingMap.put( entityName, rootEntityBinding );
    }
    return rootEntityBinding;
  }
View Full Code Here

    return identifierGeneratorFactory;
  }

  @Override
  public Type getIdentifierType(String entityName) throws MappingException {
    EntityBinding entityBinding = getEntityBinding( entityName );
    if ( entityBinding == null ) {
      throw new MappingException( "Entity binding not known: " + entityName );
    }
    return entityBinding
        .getEntityIdentifier()
        .getValueBinding()
        .getHibernateTypeDescriptor()
        .getExplicitType();
  }
View Full Code Here

        .getExplicitType();
  }

  @Override
  public String getIdentifierPropertyName(String entityName) throws MappingException {
    EntityBinding entityBinding = getEntityBinding( entityName );
    if ( entityBinding == null ) {
      throw new MappingException( "Entity binding not known: " + entityName );
    }
    AttributeBinding idBinding = entityBinding.getEntityIdentifier().getValueBinding();
    return idBinding == null ? null : idBinding.getAttribute().getName();
  }
View Full Code Here

    return idBinding == null ? null : idBinding.getAttribute().getName();
  }

  @Override
  public Type getReferencedPropertyType(String entityName, String propertyName) throws MappingException {
    EntityBinding entityBinding = getEntityBinding( entityName );
    if ( entityBinding == null ) {
      throw new MappingException( "Entity binding not known: " + entityName );
    }
    // TODO: should this call EntityBinding.getReferencedAttributeBindingString), which does not exist yet?
    AttributeBinding attributeBinding = entityBinding.getAttributeBinding( propertyName );
    if ( attributeBinding == null ) {
      throw new MappingException( "unknown property: " + entityName + '.' + propertyName );
    }
    return attributeBinding.getHibernateTypeDescriptor().getExplicitType();
  }
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();
          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

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.