//@SuppressWarnings({"unchecked"})
        public IdMappingData AddId(PersistentClass pc)
        {
            // Xml mapping which will be used for relations
            XmlDocument id_mappingDoc = new XmlDocument();
            XmlElement rel_id_mapping = id_mappingDoc.CreateElement("properties"); //= new DefaultElement("properties"); // (din DOM4J)
            // Xml mapping which will be used for the primary key of the versions table
            XmlElement orig_id_mapping = id_mappingDoc.CreateElement("composite-id");  //= new DefaultElement("composite-id"); // (din DOM4J)

            Property id_prop = pc.IdentifierProperty;
            Component id_mapper = pc.IdentifierMapper;

            // Checking if the id mapping is supported
            if (id_mapper == null && id_prop == null) {
            return null;
            }

            ISimpleIdMapperBuilder mapper;
            if (id_mapper != null) {
            // Multiple id

            mapper = new MultipleIdMapper(((Component)pc.Identifier).ComponentClass);
            AddIdProperties(rel_id_mapping, (IEnumerator<Property>)id_mapper.PropertyIterator, mapper, false);

            // null mapper - the mapping where already added the first time, now we only want to generate the xml
            AddIdProperties(orig_id_mapping, (IEnumerator<Property>)id_mapper.PropertyIterator, null, true);
            } else if (id_prop.IsComposite) {
            // Embedded id

            Component id_component = (Component) id_prop.Value;

            mapper = new EmbeddedIdMapper(GetIdPropertyData(id_prop), id_component.ComponentClass);
            AddIdProperties(rel_id_mapping, (IEnumerator<Property>)id_component.PropertyIterator, mapper, false);

            // null mapper - the mapping where already added the first time, now we only want to generate the xml
            AddIdProperties(orig_id_mapping, (IEnumerator<Property>)id_component.PropertyIterator, null, true);
            } else {
            // Single id

            mapper = new SingleIdMapper();

            // Last but one parameter: ids are always insertable
            mainGenerator.BasicMetadataGenerator.AddBasic(rel_id_mapping,
                    GetIdPersistentPropertyAuditingData(id_prop),
                    id_prop.Value, mapper, true, false);

            // null mapper - the mapping where already added the first time, now we only want to generate the xml
            mainGenerator.BasicMetadataGenerator.AddBasic(orig_id_mapping,
                    GetIdPersistentPropertyAuditingData(id_prop),
                    id_prop.Value, null, true, true);
            }

            orig_id_mapping.SetAttribute("name", mainGenerator.VerEntCfg.OriginalIdPropName);

            // Adding a relation to the revision entity (effectively: the "revision number" property)
            mainGenerator.AddRevisionInfoRelation(orig_id_mapping);

            return new IdMappingData(mapper, orig_id_mapping, rel_id_mapping);
        }
        public override IIdMapper PrefixMappedProperties(String prefix)
        {
            MultipleIdMapper ret = new MultipleIdMapper(compositeIdClass);

            foreach (PropertyData propertyData in ids.Keys) {
            String propertyName = propertyData.Name;
            ret.ids.Add(propertyData, new SingleIdMapper(new PropertyData(prefix + propertyName, propertyData)));
            }

            return ret;
        }
        public override IIdMapper PrefixMappedProperties(String prefix)
        {
            MultipleIdMapper ret = new MultipleIdMapper(compositeIdClass);

            foreach (PropertyData propertyData in ids.Keys)
            {
                String propertyName = propertyData.Name;
                ret.ids.Add(propertyData, new SingleIdMapper(new PropertyData(prefix + propertyName, propertyData)));
            }

            return(ret);
        }