Package org.hibernate.mapping

Examples of org.hibernate.mapping.Component


        int dotIndex = name.lastIndexOf( '.' );
        String reducedName = name.substring( 0, dotIndex );
        Value value = pc.getRecursiveProperty( reducedName ).getValue();
        Iterator parentPropIter;
        if ( value instanceof Component ) {
          Component comp = (Component) value;
          parentPropIter = comp.getPropertyIterator();
        }
        else if ( value instanceof ToOne ) {
          ToOne toOne = (ToOne) value;
          PersistentClass referencedPc = mappings.getClass( toOne.getReferencedEntityName() );
          if ( toOne.getReferencedPropertyName() != null ) {
View Full Code Here


    }
    else {
      proxyFactory = null;
    }
   
    Component mapper = mappingInfo.getIdentifierMapper();
    identifierMapperType = mapper==null ? null : (AbstractComponentType) mapper.getType();
  }
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

          false, mappings
      );
      inferredData = new PropertyPreloadedData(
          propertyAccessor, "_identifierMapper", compositeClass
      );
      Component mapper = fillComponent(
          propertyHolder,
          inferredData,
          propertyAnnotated,
          propertyAccessor, false,
          entityBinder,
          true, true,
          false, mappings
      );
      entityBinder.setIgnoreIdAnnotations( ignoreIdAnnotations );
      persistentClass.setIdentifierMapper( mapper );
      Property property = new Property();
      property.setName( "_identifierMapper" );
      property.setNodeName( "id" );
      property.setUpdateable( false );
      property.setInsertable( false );
      property.setValue( mapper );
      property.setPropertyAccessorName( "embedded" );
      persistentClass.addProperty( property );
      entityBinder.setIgnoreIdAnnotations( true );

      Iterator properties = mapper.getPropertyIterator();
      while ( properties.hasNext() ) {
        idProperties.add( ( (Property) properties.next() ).getName() );
      }
    }
    Set<String> missingIdProperties = new HashSet<String>( idProperties );
View Full Code Here

      boolean propertyAnnotated,
      String propertyAccessor, EntityBinder entityBinder,
      boolean isIdentifierMapper,
      ExtendedMappings mappings, boolean isComponentEmbedded
  ) {
    Component comp = fillComponent(
        propertyHolder, inferredData, propertyAnnotated, propertyAccessor, true, entityBinder,
        isComponentEmbedded, isIdentifierMapper,
        false, mappings
    );
    XProperty property = inferredData.getProperty();
View Full Code Here

    /**
     * inSecondPass can only be used to apply right away the second pass of a composite-element
     * Because it's a value type, there is no bidirectional association, hence second pass
     * ordering does not matter
     */
    Component comp = new Component( propertyHolder.getPersistentClass() );
    comp.setEmbedded( isComponentEmbedded );
    //yuk
    comp.setTable( propertyHolder.getTable() );
    if ( !isIdentifierMapper ) {
      comp.setComponentClassName( inferredData.getClassOrElementName() );
    }
    else {
      comp.setComponentClassName( comp.getOwner().getClassName() );
    }
    comp.setNodeName( inferredData.getPropertyName() );
    String subpath = StringHelper.qualify( propertyHolder.getPath(), inferredData.getPropertyName() );
    log.debug( "Binding component with path: {}", subpath );
    PropertyHolder subHolder = PropertyHolderBuilder.buildPropertyHolder(
        comp, subpath,
        inferredData, propertyHolder, mappings
View Full Code Here

    if ( isComposite ) {
      id = fillComponent(
          propertyHolder, inferredData, isPropertyAnnotated, propertyAccessor,
          false, entityBinder, isEmbedded, isIdentifierMapper, false, mappings
      );
      Component componentId = (Component) id;
      componentId.setKey( true );
      if ( rootClass.getIdentifier() != null ) {
        throw new AnnotationException( componentId.getComponentClassName() + " must not have @Id properties when used as an @EmbeddedId" );
      }
      if ( componentId.getPropertySpan() == 0 ) {
        throw new AnnotationException( componentId.getComponentClassName() + " has no persistent id property" );
      }
      //tuplizers
      XProperty property = inferredData.getProperty();
      setupComponentTuplizer( property, componentId );
    }
View Full Code Here

    while ( propertyIterator.hasNext() ) {

      Property prop = ( Property ) propertyIterator.next();
      String propname = path == null ? prop.getName() : path + "." + prop.getName();
      if ( prop.isComposite() ) {
        Component component = ( Component ) prop.getValue();
        Iterator compProps = component.getPropertyIterator();
        internalInitSubclassPropertyAliasesMap( propname, compProps );
      }
      else {
        String[] aliases = new String[prop.getColumnSpan()];
        String[] cols = new String[prop.getColumnSpan()];
View Full Code Here

          //boolean propertyAccess = embeddable == null || AccessType.PROPERTY.equals( embeddable.access() );
          //FIXME "index" is it right?
          PropertyData inferredData = new PropertyPreloadedData( "property", "index", elementClass );
          //TODO be smart with isNullable
          Component component = AnnotationBinder.fillComponent(
              holder, inferredData, isPropertyAnnotated, isPropertyAnnotated ? "property" : "field", true,
              entityBinder, false, false,
              true, mappings
          );
          mapValue.setIndex( component );
View Full Code Here

      }
      fromAndWhere = fromAndWhereSb.substring( 0, fromAndWhereSb.length() - 5 );
    }

    if ( value instanceof Component ) {
      Component component = (Component) value;
      Iterator properties = component.getPropertyIterator();
      Component indexComponent = new Component( collection );
      indexComponent.setComponentClassName( component.getComponentClassName() );
      //TODO I don't know if this is appropriate
      indexComponent.setNodeName( "index" );
      while ( properties.hasNext() ) {
        Property current = (Property) properties.next();
        Property newProperty = new Property();
        newProperty.setCascade( current.getCascade() );
        newProperty.setGeneration( current.getGeneration() );
        newProperty.setInsertable( false );
        newProperty.setUpdateable( false );
        newProperty.setMetaAttributes( current.getMetaAttributes() );
        newProperty.setName( current.getName() );
        newProperty.setNodeName( current.getNodeName() );
        newProperty.setNaturalIdentifier( false );
        //newProperty.setOptimisticLocked( false );
        newProperty.setOptional( false );
        newProperty.setPersistentClass( current.getPersistentClass() );
        newProperty.setPropertyAccessorName( current.getPropertyAccessorName() );
        newProperty.setSelectable( current.isSelectable() );
        newProperty.setValue( createFormulatedValue( current.getValue(), collection, targetPropertyName,
            associatedClass
        ) );
        indexComponent.addProperty( newProperty );
      }
      return indexComponent;
    }
    else if ( value instanceof SimpleValue ) {
      SimpleValue sourceValue = (SimpleValue) value;
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.