Пример #1
0
        private void addValueInFirstPass(XElement parent, IValue value, ICompositeMapperBuilder currentMapper, string entityName,
                                         EntityXmlMappingData xmlMappingData, PropertyAuditingData propertyAuditingData,
                                         bool insertable, bool processModifiedFlag)
        {
            var type = value.Type;

            if (BasicMetadataGenerator.AddBasic(parent, propertyAuditingData, value, currentMapper, insertable, false))
            {
                // The property was mapped by the basic generator.
            }
            else if (type is ComponentType)
            {
                componentMetadataGenerator.AddComponent(parent, propertyAuditingData, value, currentMapper, entityName,
                                                        xmlMappingData, true, insertable);
            }
            else
            {
                if (!processedInSecondPass(type))
                {
                    // If we got here in the first pass, it means the basic mapper didn't map it, and none of the
                    // above branches either.
                    ThrowUnsupportedTypeException(type, entityName, propertyAuditingData.Name);
                }
                return;
            }
            addModifiedFlagIfNeeded(parent, propertyAuditingData, processModifiedFlag);
        }
        //@SuppressWarnings({"unchecked"})
        public void AddValue(XmlElement parent, IValue value, ICompositeMapperBuilder currentMapper, String entityName,
                      EntityXmlMappingData xmlMappingData, PropertyAuditingData propertyAuditingData,
                      bool insertable, bool firstPass)
        {
            IType type = value.Type;

            // only first pass
            if (firstPass)
            {
                if (BasicMetadataGenerator.AddBasic(parent, propertyAuditingData, value, currentMapper,
                        insertable, false))
                {
                    // The property was mapped by the basic generator.
                    return;
                }
            }

            if (type is ComponentType)
            {
                // both passes
                componentMetadataGenerator.AddComponent(parent, propertyAuditingData, value, currentMapper,
                        entityName, xmlMappingData, firstPass);
            }
            else if (type is ManyToOneType)
            {
                // only second pass
                if (!firstPass)
                {
                    toOneRelationMetadataGenerator.AddToOne(parent, propertyAuditingData, value, currentMapper,
                            entityName, insertable);
                }
            }
            else if (type is OneToOneType)
            {
                // only second pass
                if (!firstPass)
                {
                    toOneRelationMetadataGenerator.AddOneToOneNotOwning(propertyAuditingData, value,
                            currentMapper, entityName);
                }
            }
            else if (type is CollectionType)
            {
                // only second pass
                if (!firstPass)
                {
                    CollectionMetadataGenerator collectionMetadataGenerator = new CollectionMetadataGenerator(this,
                            (Mapping.Collection)value, currentMapper, entityName, xmlMappingData,
                            propertyAuditingData);
                    collectionMetadataGenerator.AddCollection();
                }
            }
            else
            {
                if (firstPass)
                {
                    // If we got here in the first pass, it means the basic mapper didn't map it, and none of the
                    // above branches either.
                    ThrowUnsupportedTypeException(type, entityName, propertyAuditingData.Name);
                }
            }
        }