Package org.hibernate.metamodel.binding

Examples of org.hibernate.metamodel.binding.BasicAttributeBinding


   */
  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


      }
    }
  }

  private void bindSimpleIdentifier(SimpleIdentifierSource identifierSource, EntityBinding entityBinding) {
    final BasicAttributeBinding idAttributeBinding = doBasicSingularAttributeBindingCreation(
        identifierSource.getIdentifierAttributeSource(), entityBinding
    );

    entityBinding.getHierarchyDetails().getEntityIdentifier().setValueBinding( idAttributeBinding );
    IdGenerator generator = identifierSource.getIdentifierGeneratorDescriptor();
    if ( generator == null ) {
      Map<String, String> params = new HashMap<String, String>();
      params.put( IdentifierGenerator.ENTITY_NAME, entityBinding.getEntity().getName() );
      generator = new IdGenerator( "default_assign_identity_generator", "assigned", params );
    }
    entityBinding.getHierarchyDetails()
        .getEntityIdentifier()
        .setIdGenerator( generator );

    final org.hibernate.metamodel.relational.Value relationalValue = idAttributeBinding.getValue();

    if ( SimpleValue.class.isInstance( relationalValue ) ) {
      if ( !Column.class.isInstance( relationalValue ) ) {
        // this should never ever happen..
        throw new AssertionFailure( "Simple-id was not a column." );
View Full Code Here

    final SingularAttributeSource versioningAttributeSource = entitySource.getVersioningAttributeSource();
    if ( versioningAttributeSource == null ) {
      return;
    }

    BasicAttributeBinding attributeBinding = doBasicSingularAttributeBindingCreation(
        versioningAttributeSource, entityBinding
    );
    entityBinding.getHierarchyDetails().setVersioningAttributeBinding( attributeBinding );
  }
View Full Code Here

    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

    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

    }

    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

    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

   * @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

    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

   */
  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

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.