示例#1
0
        private Tuple <XElement, IExtendedPropertyMapper, string> generateMappingData(
            PersistentClass pc, EntityXmlMappingData xmlMappingData, AuditTableData auditTableData,
            IdMappingData idMapper)
        {
            var hasDiscriminator = pc.Discriminator != null;

            var classMapping = MetadataTools.CreateEntity(xmlMappingData.MainXmlMapping, auditTableData,
                                                          hasDiscriminator ? pc.DiscriminatorValue : null, pc.IsAbstract.HasValue && pc.IsAbstract.Value);
            var propertyMapper = new MultiPropertyMapper();

            // Adding the id mapping
            classMapping.Add(idMapper.XmlMapping);

            // Checking if there is a discriminator column
            if (hasDiscriminator)
            {
                var discriminatorElement = new XElement(MetadataTools.CreateElementName("discriminator"));
                classMapping.Add(discriminatorElement);
                // Database column or SQL formula allowed to distinguish entity types
                MetadataTools.AddColumnsOrFormulas(discriminatorElement, pc.Discriminator.ColumnIterator);
                discriminatorElement.Add(new XAttribute("type", pc.Discriminator.Type.Name));
            }

            // Adding the "revision type" property
            AddRevisionType(classMapping, classMapping);

            return(new Tuple <XElement, IExtendedPropertyMapper, string>(classMapping, propertyMapper, null));
        }
        //@SuppressWarnings({"unchecked"})
        private Triple<XmlElement, IExtendedPropertyMapper, String> GenerateMappingData(
                PersistentClass pc, EntityXmlMappingData xmlMappingData, AuditTableData auditTableData,
                IdMappingData idMapper)
        {
            bool hasDiscriminator = pc.Discriminator != null;

            XmlElement class_mapping = MetadataTools.CreateEntity(xmlMappingData.MainXmlMapping, auditTableData,
                    hasDiscriminator ? pc.DiscriminatorValue : null);
            IExtendedPropertyMapper propertyMapper = new MultiPropertyMapper();

            // Checking if there is a discriminator column
            if (hasDiscriminator)
            {
                XmlElement discriminator_element = class_mapping.OwnerDocument.CreateElement("discriminator");
                class_mapping.AppendChild(discriminator_element);
                MetadataTools.AddColumns(discriminator_element, (IEnumerator<ISelectable>)pc.Discriminator.ColumnIterator.GetEnumerator());
                discriminator_element.SetAttribute("type", pc.Discriminator.Type.Name);
            }

            InheritanceType.Type parentInheritance = InheritanceType.GetForParent(pc);
            switch (parentInheritance)
            {
                case InheritanceType.Type.NONE:
                    break;

                case InheritanceType.Type.SINGLE:
                    AddSingleInheritancePersisterHack(class_mapping);
                    break;

                case InheritanceType.Type.JOINED:
                    AddJoinedInheritancePersisterHack(class_mapping);
                    break;

                case InheritanceType.Type.TABLE_PER_CLASS:
                    AddTablePerClassInheritancePersisterHack(class_mapping);
                    break;
            }

            // Adding the id mapping
            XmlNode xmlMp = class_mapping.OwnerDocument.ImportNode(idMapper.XmlMapping,true);
            class_mapping.AppendChild(xmlMp);

            // Adding the "revision type" property
            AddRevisionType(class_mapping);

            return Triple<XmlElement, IExtendedPropertyMapper, string>.Make<XmlElement, IExtendedPropertyMapper, string>(class_mapping, propertyMapper, null);
        }
示例#3
0
 public MiddleEmbeddableComponentMapper(MultiPropertyMapper theDelegate, string componentClassName)
 {
     _delegate       = theDelegate;
     _componentClass = Toolz.ResolveDotnetType(componentClassName);
 }