Package org.hibernate.mapping

Examples of org.hibernate.mapping.Component


      List<Property> properties = findPropertiesByColumns( columnOwner, columns, mappings );
      //create an embeddable component
                        Property synthProp = null;
      if ( properties != null ) {
                        //todo how about properties.size() == 1, this should be much simpler
        Component embeddedComp = columnOwner instanceof PersistentClass ?
            new Component( mappings, (PersistentClass) columnOwner ) :
            new Component( mappings, (Join) columnOwner );
        embeddedComp.setEmbedded( true );
        embeddedComp.setNodeName( syntheticPropertyName );
        embeddedComp.setComponentClassName( embeddedComp.getOwner().getClassName() );
        for (Property property : properties) {
          Property clone = BinderHelper.shallowCopy( property );
          clone.setInsertable( false );
          clone.setUpdateable( false );
          clone.setNaturalIdentifier( false );
          clone.setValueGenerationStrategy( property.getValueGenerationStrategy() );
          embeddedComp.addProperty( clone );
                                }
                                    synthProp = new SyntheticProperty();
        synthProp.setName( syntheticPropertyName );
        synthProp.setNodeName( syntheticPropertyName );
        synthProp.setPersistentClass( ownerEntity );
View Full Code Here


      throw new AssertionFailure(
          "Unexpected identifier type on the referenced entity when mapping a @MapsId: "
              + referencedEntityName
      );
    }
    Component referencedComponent = (Component) referencedPersistentClass.getIdentifier();
    Iterator<Property> properties = referencedComponent.getPropertyIterator();


    //prepare column name structure
    boolean isExplicitReference = true;
    Map<String, Ejb3JoinColumn> columnByReferencedName = new HashMap<String, Ejb3JoinColumn>(joinColumns.length);
View Full Code Here

    }
    else {
      proxyFactory = null;
    }

    Component mapper = mappingInfo.getIdentifierMapper();
    if ( mapper == null ) {
      identifierMapperType = null;
      mappedIdentifierValueMarshaller = null;
    }
    else {
      identifierMapperType = (CompositeType) mapper.getType();
      mappedIdentifierValueMarshaller = buildMappedIdentifierValueMarshaller(
          (ComponentType) entityMetamodel.getIdentifierProperty().getType(),
          (ComponentType) identifierMapperType
      );
    }
View Full Code Here

    }


    // TODO: Fix this when components are working (HHH-6173)
    //Component mapper = mappingInfo.getEntityIdentifier().getIdentifierMapper();
    Component mapper = null;
    if ( mapper == null ) {
      identifierMapperType = null;
      mappedIdentifierValueMarshaller = null;
    }
    else {
      identifierMapperType = ( CompositeType ) mapper.getType();
      mappedIdentifierValueMarshaller = buildMappedIdentifierValueMarshaller(
          ( ComponentType ) entityMetamodel.getIdentifierProperty().getType(),
          ( ComponentType ) identifierMapperType
      );
    }
View Full Code Here

      else if ( hadInMemoryGeneration ) {
        throw new NotYetImplementedException( "Still need to wire in composite in-memory value generation" );

      }
      else if ( hadInDatabaseGeneration ) {
        final Component composite = (Component) mappingProperty.getValue();

        // we need the numbers to match up so we can properly handle 'referenced sql column values'
        if ( inDatabaseStrategies.size() != composite.getPropertySpan() ) {
          throw new ValueGenerationStrategyException(
              "Internal error : mismatch between number of collected in-db generation strategies" +
                  " and number of attributes for composite attribute : " + mappingProperty.getName()
          );
        }

        // the base-line values for the aggregated InDatabaseValueGenerationStrategy we will build here.
        GenerationTiming timing = GenerationTiming.INSERT;
        boolean referenceColumns = false;
        String[] columnValues = new String[ composite.getColumnSpan() ];

        // start building the aggregate values
        int propertyIndex = -1;
        int columnIndex = 0;
        Iterator subProperties = composite.getPropertyIterator();
        while ( subProperties.hasNext() ) {
          propertyIndex++;
          final Property subProperty = (Property) subProperties.next();
          final InDatabaseValueGenerationStrategy subStrategy = inDatabaseStrategies.get( propertyIndex );
View Full Code Here

  }

  @SuppressWarnings( "unchecked" )
  private void addSubElement(Property property, ValidatableElement element) {
    if ( property != null && property.isComposite() && !property.isBackRef() ) {
      Component component = (Component) property.getValue();
      if ( component.isEmbedded() ) return;
      PropertyAccessor accessor = PropertyAccessorFactory.getPropertyAccessor( property, EntityMode.POJO );
      Getter getter = accessor.getGetter( element.clazz, property.getName() );
      ClassValidator validator = new ClassValidator( getter.getReturnType() );
      ValidatableElement subElement = new ValidatableElement( getter.getReturnType(), validator, getter );
      Iterator properties = component.getPropertyIterator();
      while ( properties.hasNext() ) {
        addSubElement( (Property) properties.next(), subElement );
      }
      if ( subElement.getSubElements().size() != 0 || subElement.validator.hasValidationRules() ) {
        element.addSubElement( subElement );
View Full Code Here

      jpaEntityType.getBuilder().applyIdClassAttributes( buildIdClassAttributes( jpaEntityType, persistentClass ) );
    }
    else {
      final KeyValue value = persistentClass.getIdentifier();
      if (value instanceof Component ) {
        final Component component = ( Component ) value;
        if ( component.getPropertySpan() > 1 ) {
          //FIXME we are an Hibernate embedded id (ie not type)
        }
        else {
          //FIXME take care of declared vs non declared property
          jpaEntityType.getBuilder().applyIdAttribute(
            attributeFactory.buildIdAttribute(
                jpaEntityType,
                (Property) component.getPropertyIterator().next() )
          );
        }
      }
    }
  }
View Full Code Here

      jpaEntityType.getBuilder().applyIdClassAttributes( attributes );
    }
    else {
      final KeyValue value = persistentClass.getIdentifier();
      if (value instanceof Component ) {
        final Component component = ( Component ) value;
        if ( component.getPropertySpan() > 1 ) {
          //FIXME we are an Hibernate embedded id (ie not type)
        }
        else {
          //FIXME take care of declared vs non declared property
          jpaEntityType.getBuilder().applyIdAttribute(
            attributeFactory.buildIdAttribute(
                jpaEntityType,
                (Property) component.getPropertyIterator().next() )
          );
        }
      }
    }
  }
View Full Code Here

      case ENTITY: {
        final org.hibernate.type.EntityType type = (EntityType) typeContext.getValue().getType();
        return (Type<Y>) context.locateEntityType( type.getAssociatedEntityName() );
      }
      case EMBEDDABLE: {
        final Component component = (Component) typeContext.getValue();
        final EmbeddableTypeImpl<Y> embeddableType = new EmbeddableTypeImpl<Y>(
            typeContext.getBindableType(),
            typeContext.getAttributeMetadata().getOwnerType(),
            (ComponentType) typeContext.getValue().getType()
        );
        context.registerEmbeddedableType( embeddableType );
        final Iterator<Property> subProperties = component.getPropertyIterator();
        while ( subProperties.hasNext() ) {
          final Property property = subProperties.next();
          final AttributeImplementor<Y, Object> attribute = buildAttribute( embeddableType, property );
          if ( attribute != null ) {
            embeddableType.getBuilder().addAttribute( attribute );
View Full Code Here

      case ENTITY: {
        final org.hibernate.type.EntityType type = (EntityType) typeContext.getValue().getType();
        return (Type<Y>) context.locateEntityType( type.getAssociatedEntityName() );
      }
      case EMBEDDABLE: {
        final Component component = (Component) typeContext.getValue();
        final EmbeddableTypeImpl<Y> embeddableType = new EmbeddableTypeImpl<Y>(
            typeContext.getBindableType(),
            typeContext.getAttributeMetadata().getOwnerType(),
            (ComponentType) typeContext.getValue().getType()
        );
        context.registerEmbeddedableType( embeddableType );
        final Iterator<Property> subProperties = component.getPropertyIterator();
        while ( subProperties.hasNext() ) {
          final Property property = subProperties.next();
          final AttributeImplementor<Y, Object> attribute = buildAttribute( embeddableType, property );
          if ( attribute != null ) {
            embeddableType.getBuilder().addAttribute( attribute );
View Full Code Here

TOP

Related Classes of org.hibernate.mapping.Component

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.