Package org.hibernate.metamodel.binding

Examples of org.hibernate.metamodel.binding.SimpleAttributeBinding$DomainState


// todo : implement
//        value = new OneToOne( mappings, table, persistentClass );
//        bindOneToOne( subElement, (OneToOne) value, propertyName, true, mappings );
      }
      else if ( "property".equals( subElementName ) ) {
        SimpleAttributeBinding binding = entityBinding.makeSimpleAttributeBinding( propertyName );
        bindSimpleAttribute( subElement, binding, entityBinding, propertyName );
        attributeBinding = binding;
      }
      else if ( "component".equals( subElementName )
          || "dynamic-component".equals( subElementName )
View Full Code Here


    // Handle the domain portion of the binding...
    final String explicitName = identifierElement.attributeValue( "name" );
    final String attributeName = explicitName == null ? RootClass.DEFAULT_IDENTIFIER_COLUMN_NAME : explicitName;
    entityBinding.getEntity().getOrCreateSingularAttribute( attributeName );

    SimpleAttributeBinding idBinding = entityBinding.makeSimpleAttributeBinding( attributeName );

    basicAttributeBinding( identifierElement, idBinding );

    // Handle the relational portion of the binding...
    Value idValue = processValues( identifierElement, entityBinding.getBaseTable(), attributeName );
    idBinding.setValue( idValue );

    // ear-mark this value binding as the identifier...
    entityBinding.getEntityIdentifier().setValueBinding( idBinding );

    if ( idValue instanceof Tuple ) {
View Full Code Here

    final String explicitName = discriminatorElement.attributeValue( "name" );
    final String attributeName = explicitName == null ? RootClass.DEFAULT_DISCRIMINATOR_COLUMN_NAME : explicitName;
    entityBinding.getEntity().getOrCreateSingularAttribute( attributeName );

    SimpleAttributeBinding discriminatorBinding = entityBinding.makeSimpleAttributeBinding( attributeName );
    basicAttributeBinding( discriminatorElement, discriminatorBinding );
    if ( discriminatorBinding.getHibernateTypeDescriptor().getTypeName() == null ) {
      discriminatorBinding.getHibernateTypeDescriptor().setTypeName( "string" );
    }

    // Handle the relational portion of the binding...
    Value discriminatorValue = processValues( discriminatorElement, entityBinding.getBaseTable(), attributeName );
    discriminatorBinding.setValue( discriminatorValue );

    // ear-mark this value binding as the discriminator...
    entityBinding.makeEntityDiscriminator();
    entityBinding.getEntityDiscriminator().setValueBinding( discriminatorBinding );
View Full Code Here

    final String explicitName = versioningElement.attributeValue( "name" );
    if ( explicitName == null ) {
      throw new MappingException( "Mising property name for version/timestamp mapping [" + entityBinding.getEntity().getName() + "]" );
    }
    entityBinding.getEntity().getOrCreateSingularAttribute( explicitName );
    SimpleAttributeBinding versionBinding = entityBinding.makeSimpleAttributeBinding( explicitName );
    basicAttributeBinding( versioningElement, versionBinding );

    if ( versionBinding.getHibernateTypeDescriptor().getTypeName() == null ) {
      if ( isVersion ) {
        versionBinding.getHibernateTypeDescriptor().setTypeName( "integer" );
      }
      else {
        final String tsSource = versioningElement.attributeValue( "source" );
        if ( "db".equals( tsSource ) ) {
          versionBinding.getHibernateTypeDescriptor().setTypeName( "dbtimestamp" );
        }
        else {
          versionBinding.getHibernateTypeDescriptor().setTypeName( "timestamp" );
        }
      }
    }

    // Handle the relational portion of the binding...
    Value discriminatorValue = processValues( versioningElement, entityBinding.getBaseTable(), explicitName );
    versionBinding.setValue( discriminatorValue );

    // for version properties marked as being generated, make sure they are "always"
    // generated; aka, "insert" is invalid; this is dis-allowed by the DTD,
    // but just to make sure...
    if ( versionBinding.getGeneration() == PropertyGeneration.INSERT ) {
      throw new MappingException( "'generated' attribute cannot be 'insert' for versioning property" );
    }

    entityBinding.setVersioningValueBinding( versionBinding );
  }
View Full Code Here

    }

    SingularAttribute attribute = entityBinding.getEntity().getOrCreateComponentAttribute( idName );


    SimpleAttributeBinding attributeBinding = entityBinding.makeSimpleIdAttributeBinding( attribute );

    attributeBinding.initialize( new AttributeBindingStateImpl( (SimpleAttribute) idAttribute ) );

    TupleRelationalStateImpl state = new TupleRelationalStateImpl();
    EmbeddableClass embeddableClass = entityClass.getEmbeddedClasses().get( idName );
    for ( SimpleAttribute attr : embeddableClass.getSimpleAttributes() ) {
      state.addValueState( new ColumnRelationalStateImpl( attr, meta ) );
    }
    attributeBinding.initialize( state );
    Map<String, String> parms = new HashMap<String, String>( 1 );
    parms.put( IdentifierGenerator.ENTITY_NAME, entityBinding.getEntity().getName() );
    IdGenerator generator = new IdGenerator( "NAME", "assigned", parms );
    entityBinding.getEntityIdentifier().setIdGenerator( generator );
    // entityBinding.getEntityIdentifier().createIdentifierGenerator( meta.getIdentifierGeneratorFactory() );
View Full Code Here

    // now that we have the id attribute we can create the attribute and binding
    MappedAttribute idAttribute = iter.next();
    Attribute attribute = container.getOrCreateSingularAttribute( idAttribute.getName() );

    SimpleAttributeBinding attributeBinding = entityBinding.makeSimpleIdAttributeBinding( attribute );
    attributeBinding.initialize( new AttributeBindingStateImpl( (SimpleAttribute) idAttribute ) );
    attributeBinding.initialize( new ColumnRelationalStateImpl( (SimpleAttribute) idAttribute, meta ) );
    bindSingleIdGeneratedValue( entityBinding, idAttribute.getName() );
  }
View Full Code Here

    if ( simpleAttribute.isId() ) {
      return;
    }

    Attribute attribute = container.getOrCreateSingularAttribute( simpleAttribute.getName() );
    SimpleAttributeBinding attributeBinding;

    if ( simpleAttribute.isDiscriminator() ) {
      EntityDiscriminator entityDiscriminator = entityBinding.makeEntityDiscriminator( attribute );
      DiscriminatorBindingState bindingState = new DiscriminatorBindingStateImpl( simpleAttribute );
      entityDiscriminator.initialize( bindingState );
      attributeBinding = entityDiscriminator.getValueBinding();
    }
    else if ( simpleAttribute.isVersioned() ) {
      attributeBinding = entityBinding.makeVersionBinding( attribute );
      SimpleAttributeBindingState bindingState = new AttributeBindingStateImpl( simpleAttribute );
      attributeBinding.initialize( bindingState );
    }
    else {
      attributeBinding = entityBinding.makeSimpleAttributeBinding( attribute );
      SimpleAttributeBindingState bindingState = new AttributeBindingStateImpl( simpleAttribute );
      attributeBinding.initialize( bindingState );
    }

    if ( entityClass.hasOwnTable() ) {
      ColumnRelationalStateImpl columnRelationsState = new ColumnRelationalStateImpl(
          simpleAttribute, meta
      );
      TupleRelationalStateImpl relationalState = new TupleRelationalStateImpl();
      relationalState.addValueState( columnRelationsState );

      attributeBinding.initialize( relationalState );
    }
  }
View Full Code Here

    boolean hasLazy = false;

    // TODO: Fix after HHH-6337 is fixed; for now assume entityBinding is the root binding
    //SimpleAttributeBinding rootEntityIdentifier = entityBinding.getRootEntityBinding().getEntityIdentifier().getValueBinding();
    SimpleAttributeBinding 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 SimpleAttributeBinding property = mappedEntity.getEntityIdentifier().getValueBinding();

    // TODO: the following will cause an NPE with "virtual" IDs; how should they be set?
    final String mappedUnsavedValue = property.getUnsavedValue();
    final Type type = property.getHibernateTypeDescriptor().getExplicitType();

    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(),
          property.getNodeName(),
          type,
          mappedEntity.getEntityIdentifier().isEmbedded(),
          unsavedValue,
          generator
        );
View Full Code Here

    boolean alwaysDirtyCheck = type.isAssociationType() &&
        ( (AssociationType) type ).isAlwaysDirtyChecked();

    if ( property.isSimpleValue() ) {
      SimpleAttributeBinding simpleProperty = ( SimpleAttributeBinding ) property;
      return new StandardProperty(
          simpleProperty.getAttribute().getName(),
          simpleProperty.getNodeName(),
          type,
          lazyAvailable && simpleProperty.isLazy(),
          simpleProperty.isInsertable(),
          simpleProperty.isUpdatable(),
          simpleProperty.getGeneration() == PropertyGeneration.INSERT || simpleProperty.getGeneration() == PropertyGeneration.ALWAYS,
          simpleProperty.getGeneration() == PropertyGeneration.ALWAYS,
          simpleProperty.isNullable(),
          alwaysDirtyCheck || simpleProperty.isUpdatable(),
          simpleProperty.isOptimisticLockable(),
          // TODO: get cascadeStyle from simpleProperty when HHH-6355 is fixed; for now, assume NONE
          //simpleProperty.getCascadeStyle(),
          CascadeStyle.NONE,
          // TODO: get fetchMode() from simpleProperty when HHH-6357 is fixed; for now, assume FetchMode.DEFAULT
          //simpleProperty.getFetchMode()
View Full Code Here

TOP

Related Classes of org.hibernate.metamodel.binding.SimpleAttributeBinding$DomainState

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.