Package org.hibernate.metamodel.binding

Examples of org.hibernate.metamodel.binding.BasicAttributeBinding


    else {
      attribute = attributeBindingContainer.getAttributeContainer()
          .createSingularAttribute( attributeSource.getName() );
    }

    final BasicAttributeBinding attributeBinding;
    if ( attributeSource.getNature() == SingularAttributeNature.BASIC ) {
      attributeBinding = attributeBindingContainer.makeBasicAttributeBinding( attribute );
      resolveTypeInformation( attributeSource.getTypeInformation(), attributeBinding );
    }
    else if ( attributeSource.getNature() == SingularAttributeNature.MANY_TO_ONE ) {
      attributeBinding = attributeBindingContainer.makeManyToOneAttributeBinding( attribute );
      resolveTypeInformation( attributeSource.getTypeInformation(), attributeBinding );
      resolveToOneInformation(
          (ToOneAttributeSource) attributeSource,
          (ManyToOneAttributeBinding) attributeBinding
      );
    }
    else {
      throw new NotYetImplementedException();
    }

    attributeBinding.setGeneration( attributeSource.getGeneration() );
    attributeBinding.setLazy( attributeSource.isLazy() );
    attributeBinding.setIncludedInOptimisticLocking( attributeSource.isIncludedInOptimisticLocking() );

    attributeBinding.setPropertyAccessorName(
        Helper.getPropertyAccessorName(
            attributeSource.getPropertyAccessorName(),
            false,
            currentBindingContext.getMappingDefaults().getPropertyAccessorName()
        )
    );

    bindRelationalValues( attributeSource, attributeBinding );

    attributeBinding.setMetaAttributeContext(
        buildMetaAttributeContext(
            attributeSource.metaAttributes(),
            attributeBindingContainer.getMetaAttributeContext()
        )
    );
View Full Code Here


   * @param generator The identifier value generator to use for this identifier.
   * @return The appropriate IdentifierProperty definition.
   */
  public static IdentifierProperty buildIdentifierProperty(EntityBinding mappedEntity, IdentifierGenerator generator) {

    final BasicAttributeBinding property = mappedEntity.getHierarchyDetails().getEntityIdentifier().getValueBinding();

    // TODO: the following will cause an NPE with "virtual" IDs; how should they be set?
    // (steve) virtual attributes will still be attributes, they will simply be marked as virtual.
    //    see org.hibernate.metamodel.domain.AbstractAttributeContainer.locateOrCreateVirtualAttribute()

    final String mappedUnsavedValue = property.getUnsavedValue();
    final Type type = property.getHibernateTypeDescriptor().getResolvedTypeMapping();

    IdentifierValue unsavedValue = UnsavedValueFactory.getUnsavedIdentifierValue(
        mappedUnsavedValue,
        getGetter( property ),
        type,
        getConstructor( mappedEntity )
      );

    if ( property == null ) {
      // this is a virtual id property...
      return new IdentifierProperty(
              type,
          mappedEntity.getHierarchyDetails().getEntityIdentifier().isEmbedded(),
          mappedEntity.getHierarchyDetails().getEntityIdentifier().isIdentifierMapper(),
          unsavedValue,
          generator
        );
    }
    else {
      return new IdentifierProperty(
          property.getAttribute().getName(),
          null,
          type,
          mappedEntity.getHierarchyDetails().getEntityIdentifier().isEmbedded(),
          unsavedValue,
          generator
View Full Code Here

    boolean hasLazy = false;

    // TODO: Fix after HHH-6337 is fixed; for now assume entityBinding is the root binding
    //BasicAttributeBinding rootEntityIdentifier = entityBinding.getRootEntityBinding().getEntityIdentifier().getValueBinding();
    BasicAttributeBinding rootEntityIdentifier = entityBinding.getHierarchyDetails().getEntityIdentifier().getValueBinding();
    // entityBinding.getAttributeClosureSpan() includes the identifier binding;
    // "properties" here excludes the ID, so subtract 1 if the identifier binding is non-null
    propertySpan = rootEntityIdentifier == null ?
        entityBinding.getAttributeBindingClosureSpan() :
        entityBinding.getAttributeBindingClosureSpan() - 1;
View Full Code Here

    instrumentationMetadata = Environment.getBytecodeProvider().getEntityInstrumentationMetadata( mappedClass );

    boolean hasLazy = false;

    // TODO: Fix after HHH-6337 is fixed; for now assume entityBinding is the root binding
    BasicAttributeBinding rootEntityIdentifier = entityBinding.getHierarchyDetails().getEntityIdentifier().getValueBinding();
    // entityBinding.getAttributeClosureSpan() includes the identifier binding;
    // "properties" here excludes the ID, so subtract 1 if the identifier binding is non-null
    propertySpan = rootEntityIdentifier == null ?
        entityBinding.getAttributeBindingClosureSpan() :
        entityBinding.getAttributeBindingClosureSpan() - 1;
View Full Code Here

TOP

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

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.