Examples of MiddleComponentData


Examples of org.hibernate.envers.internal.entities.mapper.relation.MiddleComponentData

          referencedEntityName
      );
      // And adding it to the generator builder.
      queryGeneratorBuilder.addRelation( referencedIdData );

      return new MiddleComponentData(
          new MiddleRelatedComponentMapper( referencedIdData ),
          queryGeneratorBuilder.getCurrentIndex()
      );
    }
    else if ( type instanceof ComponentType ) {
      // Collection of embeddable elements.
      final Component component = (Component) value;
      final Class componentClass = ReflectionTools.loadClass(
          component.getComponentClassName(),
          mainGenerator.getClassLoaderService()
      );
      final MiddleEmbeddableComponentMapper componentMapper = new MiddleEmbeddableComponentMapper(
          new MultiPropertyMapper(),
          componentClass
      );

      final Element parentXmlMapping = xmlMapping.getParent();
      final ComponentAuditingData auditData = new ComponentAuditingData();
      final ReflectionManager reflectionManager = mainGenerator.getCfg().getReflectionManager();

      new ComponentAuditedPropertiesReader(
          ModificationStore.FULL,
          new AuditedPropertiesReader.ComponentPropertiesSource( reflectionManager, component ),
          auditData, mainGenerator.getGlobalCfg(), reflectionManager, ""
      ).read();

      // Emulating first pass.
      for ( String auditedPropertyName : auditData.getPropertyNames() ) {
        final PropertyAuditingData nestedAuditingData = auditData.getPropertyAuditingData( auditedPropertyName );
        mainGenerator.addValue(
            parentXmlMapping,
            component.getProperty( auditedPropertyName ).getValue(),
            componentMapper,
            prefix, xmlMappingData,
            nestedAuditingData,
            true,
            true,
            true
        );
      }

      // Emulating second pass so that the relations can be mapped too.
      for ( String auditedPropertyName : auditData.getPropertyNames() ) {
        final PropertyAuditingData nestedAuditingData = auditData.getPropertyAuditingData( auditedPropertyName );
        mainGenerator.addValue(
            parentXmlMapping,
            component.getProperty( auditedPropertyName ).getValue(),
            componentMapper,
            referencingEntityName,
            xmlMappingData,
            nestedAuditingData,
            true,
            false,
            true
        );
      }

      // Add an additional column holding a number to make each entry unique within the set.
      // Embeddable properties may contain null values, so cannot be stored within composite primary key.
      if ( propertyValue.isSet() ) {
        final String setOrdinalPropertyName = mainGenerator.getVerEntCfg()
            .getEmbeddableSetOrdinalPropertyName();
        final Element ordinalProperty = MetadataTools.addProperty(
            xmlMapping, setOrdinalPropertyName, "integer", true, true
        );
        MetadataTools.addColumn(
            ordinalProperty, setOrdinalPropertyName, null, null, null, null, null, null, false
        );
      }

      return new MiddleComponentData( componentMapper, 0 );
    }
    else {
      // Last but one parameter: collection components are always insertable
      final boolean mapped = mainGenerator.getBasicMetadataGenerator().addBasic(
          xmlMapping,
          new PropertyAuditingData(
              prefix,
              "field",
              ModificationStore.FULL,
              RelationTargetAuditMode.AUDITED,
              null,
              null,
              false
          ),
          value,
          null,
          true,
          true
      );

      if ( mapped ) {
        // Simple values are always stored in the first item of the array returned by the query generator.
        return new MiddleComponentData(
            new MiddleSimpleComponentMapper( mainGenerator.getVerEntCfg(), prefix ),
            0
        );
      }
      else {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.