Package org.hibernate.metamodel.binding

Examples of org.hibernate.metamodel.binding.SimpleSingularAttributeBinding


      }
    }
  }

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

    entityBinding.getEntityIdentifier().setValueBinding( idAttributeBinding );
    entityBinding.getEntityIdentifier().setIdGenerator( identifierSource.getIdentifierGeneratorDescriptor() );

    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;
    }

    SimpleSingularAttributeBinding attributeBinding = doBasicSingularAttributeBindingCreation(
        versioningAttributeSource, entityBinding
    );
    entityBinding.setVersionBinding( attributeBinding );
  }
View Full Code Here

      EntityBinding entityBinding) {
    final SingularAttribute attribute = attributeSource.isVirtualAttribute()
        ? entityBinding.getEntity().locateOrCreateVirtualAttribute( attributeSource.getName() )
        : entityBinding.getEntity().locateOrCreateSingularAttribute( attributeSource.getName() );

    final SimpleSingularAttributeBinding attributeBinding;
    if ( attributeSource.getNature() == SingularAttributeNature.BASIC ) {
      attributeBinding = entityBinding.makeSimpleAttributeBinding( attribute );
      resolveTypeInformation( attributeSource.getTypeInformation(), attributeBinding );
    }
    else if ( attributeSource.getNature() == SingularAttributeNature.MANY_TO_ONE ) {
      attributeBinding = entityBinding.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(), entityBinding.getMetaAttributeContext() )
    );

    return attributeBinding;
  }
View Full Code Here

    boolean hasLazy = false;

    // TODO: Fix after HHH-6337 is fixed; for now assume entityBinding is the root binding
    //SimpleSingularAttributeBinding rootEntityIdentifier = entityBinding.getRootEntityBinding().getEntityIdentifier().getValueBinding();
    SimpleSingularAttributeBinding rootEntityIdentifier = entityBinding.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 SimpleSingularAttributeBinding property = mappedEntity.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.getEntityIdentifier().isEmbedded(),
          mappedEntity.getEntityIdentifier().isIdentifierMapper(),
          unsavedValue,
          generator
        );
    }
    else {
      return new IdentifierProperty(
          property.getAttribute().getName(),
          null,
          type,
          mappedEntity.getEntityIdentifier().isEmbedded(),
          unsavedValue,
          generator
View Full Code Here

TOP

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

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.