public void AddOneToOneNotOwning(PropertyAuditingData propertyAuditingData, OneToOne value, ICompositeMapperBuilder mapper, string entityName)
        {
            var owningReferencePropertyName = referencePropertyName(value, entityName);

            var configuration = mainGenerator.EntitiesConfigurations[entityName];
            if (configuration == null)
            {
                throw new MappingException("An audited relation to a non-audited entity " + entityName + "!");
            }

            var ownedIdMapping = configuration.IdMappingData;

            if (ownedIdMapping == null)
            {
                throw new MappingException("An audited relation to a non-audited entity " + entityName + "!");
            }

            var lastPropertyPrefix = MappingTools.CreateToOneRelationPrefix(owningReferencePropertyName);
            var referencedEntityName = value.ReferencedEntityName;

            // Generating the id mapper for the relation
            var ownedIdMapper = ownedIdMapping.IdMapper.PrefixMappedProperties(lastPropertyPrefix);

            // Storing information about this relation
            mainGenerator.EntitiesConfigurations[entityName].AddToOneNotOwningRelation(
                    propertyAuditingData.Name, owningReferencePropertyName,
                    referencedEntityName, ownedIdMapper);

            // Adding mapper for the id
            var propertyData = propertyAuditingData.GetPropertyData();
            mapper.AddComposite(propertyData, new OneToOneNotOwningMapper(owningReferencePropertyName,
                    referencedEntityName, propertyData));
        }
        public void AddOneToOneNotOwning(PropertyAuditingData propertyAuditingData, IValue value, ICompositeMapperBuilder mapper, string entityName)
        {
            var propertyValue = (OneToOne)value;
            var owningReferencePropertyName = propertyValue.ReferencedPropertyName;             // mappedBy

            var configuration = _mainGenerator.EntitiesConfigurations[entityName];

            if (configuration == null)
            {
                throw new MappingException("An audited relation to a non-audited entity " + entityName + "!");
            }

            var ownedIdMapping = configuration.IdMappingData;

            if (ownedIdMapping == null)
            {
                throw new MappingException("An audited relation to a non-audited entity " + entityName + "!");
            }

            var lastPropertyPrefix   = MappingTools.CreateToOneRelationPrefix(owningReferencePropertyName);
            var referencedEntityName = propertyValue.ReferencedEntityName;

            // Generating the id mapper for the relation
            var ownedIdMapper = ownedIdMapping.IdMapper.PrefixMappedProperties(lastPropertyPrefix);

            // Storing information about this relation
            _mainGenerator.EntitiesConfigurations[entityName].AddToOneNotOwningRelation(
                propertyAuditingData.Name, owningReferencePropertyName,
                referencedEntityName, ownedIdMapper, MappingTools.IgnoreNotFound(value));

            // Adding mapper for the id
            var propertyData = propertyAuditingData.GetPropertyData();

            mapper.AddComposite(propertyData, new OneToOneNotOwningMapper(entityName, referencedEntityName, owningReferencePropertyName, propertyData));
        }
        //@SuppressWarnings({"unchecked"})
        public void AddOneToOneNotOwning(PropertyAuditingData propertyAuditingData, IValue value,
            ICompositeMapperBuilder mapper, String entityName)
        {
            OneToOne propertyValue = (OneToOne)value;

            String owningReferencePropertyName = propertyValue.ReferencedPropertyName; // mappedBy
            EntityConfiguration configuration = mainGenerator.EntitiesConfigurations[entityName];
            if (configuration == null) {
                throw new MappingException("An audited relation to a non-audited entity " + entityName + "!");
            }

            IdMappingData ownedIdMapping = configuration.IdMappingData;

            if (ownedIdMapping == null) {
                throw new MappingException("An audited relation to a non-audited entity " + entityName + "!");
            }

            String lastPropertyPrefix = MappingTools.createToOneRelationPrefix(owningReferencePropertyName);
            String referencedEntityName = propertyValue.ReferencedEntityName;

            // Generating the id mapper for the relation
            IIdMapper ownedIdMapper = ownedIdMapping.IdMapper.PrefixMappedProperties(lastPropertyPrefix);

            // Storing information about this relation
            mainGenerator.EntitiesConfigurations[entityName].AddToOneNotOwningRelation(
                    propertyAuditingData.Name, owningReferencePropertyName,
                    referencedEntityName, ownedIdMapper);

            // Adding mapper for the id
            PropertyData propertyData = propertyAuditingData.getPropertyData();
            mapper.AddComposite(propertyData, new OneToOneNotOwningMapper(owningReferencePropertyName,
                    referencedEntityName, propertyData));
        }
Beispiel #4
0
        private void AddMapper(CommonCollectionMapperData commonCollectionMapperData, MiddleComponentData elementComponentData,
                               MiddleComponentData indexComponentData)
        {
            IType type = propertyValue.Type;

            if (type is SortedSetType)
            {
                currentMapper.AddComposite(propertyAuditingData.getPropertyData(),
                                           new BasicCollectionMapper <IDictionary>(commonCollectionMapperData,
                                                                                   typeof(TreeSet <>), typeof(SortedSetProxy <>), elementComponentData));
            }
            else if (type is SetType)
            {
                currentMapper.AddComposite(propertyAuditingData.getPropertyData(),
                                           new BasicCollectionMapper <Set>(commonCollectionMapperData,
                                                                           typeof(HashedSet <>), typeof(SetProxy <>), elementComponentData));
            }
            else
            {
                throw new NotImplementedException();
            }
            //else if (type is SortedMapType) {
            //    // Indexed collection, so <code>indexComponentData</code> is not null.
            //    currentMapper.addComposite(propertyAuditingData.getPropertyData(),
            //            new MapCollectionMapper<Map>(commonCollectionMapperData,
            //            TreeMap.class, SortedMapProxy.class, elementComponentData, indexComponentData));
            //} else if (type is MapType) {
            //    // Indexed collection, so <code>indexComponentData</code> is not null.
            //    currentMapper.addComposite(propertyAuditingData.getPropertyData(),
            //            new MapCollectionMapper<Map>(commonCollectionMapperData,
            //            HashMap.class, MapProxy.class, elementComponentData, indexComponentData));
            //} else if (type is BagType) {
            //    currentMapper.addComposite(propertyAuditingData.getPropertyData(),
            //            new BasicCollectionMapper<List>(commonCollectionMapperData,
            //            ArrayList.class, ListProxy.class, elementComponentData));
            //} else if (type is ListType) {
            //    // Indexed collection, so <code>indexComponentData</code> is not null.
            //    currentMapper.addComposite(propertyAuditingData.getPropertyData(),
            //            new ListCollectionMapper(commonCollectionMapperData,
            //            elementComponentData, indexComponentData));
            //} else {
            //    mainGenerator.ThrowUnsupportedTypeException(type, referencingEntityName, propertyName);
            //}
        }
Beispiel #5
0
        //@SuppressWarnings({"unchecked"})
        public void AddToOne(XmlElement parent, PropertyAuditingData propertyAuditingData, IValue value,
                             ICompositeMapperBuilder mapper, String entityName, bool insertable)
        {
            String referencedEntityName = ((ToOne)value).ReferencedEntityName;

            IdMappingData idMapping = mainGenerator.GetReferencedIdMappingData(entityName, referencedEntityName,
                                                                               propertyAuditingData, true);

            String lastPropertyPrefix = MappingTools.createToOneRelationPrefix(propertyAuditingData.Name);

            // Generating the id mapper for the relation
            IIdMapper relMapper = idMapping.IdMapper.PrefixMappedProperties(lastPropertyPrefix);

            // Storing information about this relation
            mainGenerator.EntitiesConfigurations[entityName].AddToOneRelation(
                propertyAuditingData.Name, referencedEntityName, relMapper, insertable);

            // If the property isn't insertable, checking if this is not a "fake" bidirectional many-to-one relationship,
            // that is, when the one side owns the relation (and is a collection), and the many side is non insertable.
            // When that's the case and the user specified to store this relation without a middle table (using
            // @AuditMappedBy), we have to make the property insertable for the purposes of Envers. In case of changes to
            // the entity that didn't involve the relation, it's value will then be stored properly. In case of changes
            // to the entity that did involve the relation, it's the responsibility of the collection side to store the
            // proper data.
            bool nonInsertableFake;

            if (!insertable && propertyAuditingData.ForceInsertable)
            {
                nonInsertableFake = true;
                insertable        = true;
            }
            else
            {
                nonInsertableFake = false;
            }


            // Adding an element to the mapping corresponding to the references entity id's
            // Use OwnerDocument.ImportNode() instead of XmlNode.Clone();
            XmlElement properties = (XmlElement)parent.OwnerDocument.ImportNode(idMapping.XmlRelationMapping, true);

            properties.SetAttribute("name", propertyAuditingData.Name);

            MetadataTools.PrefixNamesInPropertyElement(properties, lastPropertyPrefix,
                                                       MetadataTools.GetColumnNameEnumerator((IEnumerator <ISelectable>)value.ColumnIterator.GetEnumerator()), false, insertable);
            parent.AppendChild(properties);


            // Adding mapper for the id
            PropertyData propertyData = propertyAuditingData.getPropertyData();

            mapper.AddComposite(propertyData, new ToOneIdMapper(relMapper, propertyData, referencedEntityName, nonInsertableFake));
        }
        public void AddOneToOnePrimaryKeyJoinColumn(PropertyAuditingData propertyAuditingData, IValue value, ICompositeMapperBuilder mapper, string entityName, bool insertable)
        {
            var referencedEntityName = ((ToOne)value).ReferencedEntityName;
            var idMapping            = _mainGenerator.GetReferencedIdMappingData(entityName, referencedEntityName, propertyAuditingData, true);
            var lastPropertyPrefix   = MappingTools.CreateToOneRelationPrefix(propertyAuditingData.Name);

            // Generating the id mapper for the relation
            var relMapper = idMapping.IdMapper.PrefixMappedProperties(lastPropertyPrefix);

            // Storing information about this relation
            _mainGenerator.EntitiesConfigurations[entityName].AddToOneRelation(propertyAuditingData.Name, referencedEntityName, relMapper, insertable, MappingTools.IgnoreNotFound(value));

            // Adding mapper for the id
            var propertyData = propertyAuditingData.GetPropertyData();

            mapper.AddComposite(propertyData, new OneToOnePrimaryKeyJoinColumnMapper(entityName, referencedEntityName, propertyData));
        }
Beispiel #7
0
        //@SuppressWarnings({"unchecked"})
        public void AddOneToOneNotOwning(PropertyAuditingData propertyAuditingData, IValue value,
                                         ICompositeMapperBuilder mapper, String entityName)
        {
            OneToOne propertyValue = (OneToOne)value;

            String owningReferencePropertyName = propertyValue.ReferencedPropertyName; // mappedBy
            EntityConfiguration configuration  = mainGenerator.EntitiesConfigurations[entityName];

            if (configuration == null)
            {
                throw new MappingException("An audited relation to a non-audited entity " + entityName + "!");
            }

            IdMappingData ownedIdMapping = configuration.IdMappingData;

            if (ownedIdMapping == null)
            {
                throw new MappingException("An audited relation to a non-audited entity " + entityName + "!");
            }

            String lastPropertyPrefix   = MappingTools.createToOneRelationPrefix(owningReferencePropertyName);
            String referencedEntityName = propertyValue.ReferencedEntityName;

            // Generating the id mapper for the relation
            IIdMapper ownedIdMapper = ownedIdMapping.IdMapper.PrefixMappedProperties(lastPropertyPrefix);

            // Storing information about this relation
            mainGenerator.EntitiesConfigurations[entityName].AddToOneNotOwningRelation(
                propertyAuditingData.Name, owningReferencePropertyName,
                referencedEntityName, ownedIdMapper);

            // Adding mapper for the id
            PropertyData propertyData = propertyAuditingData.getPropertyData();

            mapper.AddComposite(propertyData, new OneToOneNotOwningMapper(owningReferencePropertyName,
                                                                          referencedEntityName, propertyData));
        }
        public void AddToOne(XmlElement parent, PropertyAuditingData propertyAuditingData, IValue value,
					  ICompositeMapperBuilder mapper, string entityName, bool insertable, IEnumerable<string> fixedColumnNames)
        {
            var referencedEntityName = ((ToOne)value).ReferencedEntityName;
            var idMapping = mainGenerator.GetReferencedIdMappingData(entityName, referencedEntityName,
                    propertyAuditingData, true);

            var lastPropertyPrefix = MappingTools.CreateToOneRelationPrefix(propertyAuditingData.Name);

            // Generating the id mapper for the relation
            var relMapper = idMapping.IdMapper.PrefixMappedProperties(lastPropertyPrefix);

            // Storing information about this relation
            mainGenerator.EntitiesConfigurations[entityName].AddToOneRelation(
                    propertyAuditingData.Name, referencedEntityName, relMapper, insertable);

            // If the property isn't insertable, checking if this is not a "fake" bidirectional many-to-one relationship,
            // that is, when the one side owns the relation (and is a collection), and the many side is non insertable.
            // When that's the case and the user specified to store this relation without a middle table (using
            // @AuditMappedBy), we have to make the property insertable for the purposes of Envers. In case of changes to
            // the entity that didn't involve the relation, it's value will then be stored properly. In case of changes
            // to the entity that did involve the relation, it's the responsibility of the collection side to store the
            // proper data.
            bool nonInsertableFake;
            if (!insertable && propertyAuditingData.ForceInsertable)
            {
                nonInsertableFake = true;
                insertable = true;
            }
            else
            {
                nonInsertableFake = false;
            }

            // Adding an element to the mapping corresponding to the references entity id's
            // Use OwnerDocument.ImportNode() instead of XmlNode.Clone();
            var properties = (XmlElement)parent.OwnerDocument.ImportNode(idMapping.XmlRelationMapping,true);
            properties.SetAttribute("name",propertyAuditingData.Name);

            MetadataTools.PrefixNamesInPropertyElement(properties, lastPropertyPrefix,
                                                       fixedColumnNames == null
                                                       	? MetadataTools.GetColumnNameEnumerator(value.ColumnIterator)
                                                       	: fixedColumnNames.GetEnumerator(), false, insertable);
            parent.AppendChild(properties);

            // Adding mapper for the id
            var propertyData = propertyAuditingData.GetPropertyData();
            mapper.AddComposite(propertyData, new ToOneIdMapper(relMapper,propertyData,referencedEntityName,nonInsertableFake));
        }
Beispiel #9
0
        private void addMapper(CommonCollectionMapperData commonCollectionMapperData, MiddleComponentData elementComponentData, MiddleComponentData indexComponentData)
        {
            var propertyValueType = _propertyValue.GetType();
            var type = _propertyValue.Type;
            var embeddableElementType = isEmbeddableElementType();

            IPropertyMapper collectionMapper;
            var             collectionProxyMapperFactory = _mainGenerator.GlobalCfg.CollectionMapperFactory;

            if (_propertyAuditingData.CustomCollectionMapperFactory != null)
            {
                collectionMapper = _propertyAuditingData.CustomCollectionMapperFactory.Create(_mainGenerator.GlobalCfg.EnversProxyFactory, commonCollectionMapperData, elementComponentData, indexComponentData, embeddableElementType);
            }
            else if (propertyValueType == typeof(Set))
            {
                if (_propertyValue.IsSorted)
                {
                    var methodInfo = sortedSetDefinition.MakeGenericMethod(type.ReturnedClass.GetGenericArguments());
                    collectionMapper = (IPropertyMapper)methodInfo.Invoke(collectionProxyMapperFactory,
                                                                          new[] { _mainGenerator.GlobalCfg.EnversProxyFactory, commonCollectionMapperData, elementComponentData, _propertyValue.Comparer, embeddableElementType });
                }
                else
                {
                    var methodInfo = setDefinition.MakeGenericMethod(type.ReturnedClass.GetGenericArguments());
                    collectionMapper = (IPropertyMapper)methodInfo.Invoke(collectionProxyMapperFactory,
                                                                          new object[] { _mainGenerator.GlobalCfg.EnversProxyFactory, commonCollectionMapperData, elementComponentData, embeddableElementType });
                }
            }
            else if (propertyValueType == typeof(List))
            {
                var methodInfo = listDefinition.MakeGenericMethod(type.ReturnedClass.GetGenericArguments());
                collectionMapper = (IPropertyMapper)methodInfo.Invoke(collectionProxyMapperFactory,
                                                                      new object[] { _mainGenerator.GlobalCfg.EnversProxyFactory, commonCollectionMapperData, elementComponentData, indexComponentData, embeddableElementType });
            }
            else if (propertyValueType == typeof(Map))
            {
                if (_propertyValue.IsSorted)
                {
                    var methodInfo = sortedMapDefinition.MakeGenericMethod(type.ReturnedClass.GetGenericArguments());
                    collectionMapper = (IPropertyMapper)methodInfo.Invoke(collectionProxyMapperFactory,
                                                                          new[] { _mainGenerator.GlobalCfg.EnversProxyFactory, commonCollectionMapperData, elementComponentData, indexComponentData, _propertyValue.Comparer, embeddableElementType });
                }
                else
                {
                    var methodInfo = mapDefinition.MakeGenericMethod(type.ReturnedClass.GetGenericArguments());
                    collectionMapper = (IPropertyMapper)methodInfo.Invoke(collectionProxyMapperFactory,
                                                                          new object[] { _mainGenerator.GlobalCfg.EnversProxyFactory, commonCollectionMapperData, elementComponentData, indexComponentData, embeddableElementType });
                }
            }
            else if (propertyValueType == typeof(Bag))
            {
                var methodInfo = bagDefinition.MakeGenericMethod(type.ReturnedClass.GetGenericArguments());
                collectionMapper = (IPropertyMapper)methodInfo.Invoke(collectionProxyMapperFactory,
                                                                      new object[] { _mainGenerator.GlobalCfg.EnversProxyFactory, commonCollectionMapperData, elementComponentData, embeddableElementType });
            }
            else if (propertyValueType == typeof(IdentifierBag))
            {
                var methodInfo = idBagDefinition.MakeGenericMethod(type.ReturnedClass.GetGenericArguments());
                collectionMapper = (IPropertyMapper)methodInfo.Invoke(collectionProxyMapperFactory,
                                                                      new object[] { _mainGenerator.GlobalCfg.EnversProxyFactory, commonCollectionMapperData, elementComponentData, embeddableElementType });
            }
            else
            {
                throw new NotImplementedException("Mapped collection type " + type.Name + " is not currently supported in Envers");
            }
            _currentMapper.AddComposite(_propertyAuditingData.GetPropertyData(), collectionMapper);
        }
        public void AddToOne(XElement parent, PropertyAuditingData propertyAuditingData, IValue value,
                             ICompositeMapperBuilder mapper, string entityName, bool insertable)
        {
            var referencedEntityName = ((ToOne)value).ReferencedEntityName;
            var idMapping            = _mainGenerator.GetReferencedIdMappingData(entityName, referencedEntityName,
                                                                                 propertyAuditingData, true);

            var lastPropertyPrefix = MappingTools.CreateToOneRelationPrefix(propertyAuditingData.Name);

            // Generating the id mapper for the relation
            var relMapper = idMapping.IdMapper.PrefixMappedProperties(lastPropertyPrefix);

            // Storing information about this relation
            _mainGenerator.EntitiesConfigurations[entityName].AddToOneRelation(
                propertyAuditingData.Name, referencedEntityName, relMapper, insertable, MappingTools.IgnoreNotFound(value));

            // If the property isn't insertable, checking if this is not a "fake" bidirectional many-to-one relationship,
            // that is, when the one side owns the relation (and is a collection), and the many side is non insertable.
            // When that's the case and the user specified to store this relation without a middle table (using
            // @AuditMappedBy), we have to make the property insertable for the purposes of Envers. In case of changes to
            // the entity that didn't involve the relation, it's value will then be stored properly. In case of changes
            // to the entity that did involve the relation, it's the responsibility of the collection side to store the
            // proper data.
            bool nonInsertableFake;

            if (!insertable && propertyAuditingData.ForceInsertable)
            {
                nonInsertableFake = true;
                insertable        = true;
            }
            else
            {
                nonInsertableFake = false;
            }


            // Adding an element to the mapping corresponding to the references entity id's
            var properties = new XElement(idMapping.XmlRelationMapping);

            properties.Add(new XAttribute("name", propertyAuditingData.Name));

            MetadataTools.PrefixNamesInPropertyElement(properties, lastPropertyPrefix,
                                                       MetadataTools.GetColumnNameEnumerator(value.ColumnIterator),
                                                       false, insertable, propertyAuditingData.AccessType);

            // Extracting related id properties from properties tag
            var firstJoin = firstJoinElement(parent);

            foreach (var element in properties.Elements())
            {
                if (firstJoin == null)
                {
                    parent.Add(element);
                }
                else
                {
                    firstJoin.AddBeforeSelf(element);
                }
            }

            // Adding mapper for the id
            var propertyData = propertyAuditingData.GetPropertyData();

            mapper.AddComposite(propertyData, new ToOneIdMapper(relMapper, propertyData, referencedEntityName, nonInsertableFake));
        }
        private void addMapper(CommonCollectionMapperData commonCollectionMapperData, MiddleComponentData elementComponentData,
                               MiddleComponentData indexComponentData)
        {
            var type = _propertyValue.Type;
            var embeddableElementType = isEmbeddableElementType();

            IPropertyMapper collectionMapper;
            var             collectionProxyMapperFactory = _mainGenerator.GlobalCfg.CollectionMapperFactory;
            var             genericType = genericTypeDefinition(type);

            if (_propertyAuditingData.CustomCollectionMapperFactory != null)
            {
                collectionMapper = _propertyAuditingData.CustomCollectionMapperFactory.Create(_mainGenerator.GlobalCfg.EnversProxyFactory, commonCollectionMapperData, elementComponentData, indexComponentData, embeddableElementType);
            }
            else if (genericType == typeof(GenericSortedSetType <>))
            {
                var comparerType = createGenericComparerType(type);
                var methodInfo   = ReflectHelper.GetGenericMethodFrom <ICollectionMapperFactory>("SortedSet",
                                                                                                 type.ReturnedClass.GetGenericArguments(),
                                                                                                 new[] { typeof(IEnversProxyFactory), typeof(CommonCollectionMapperData), typeof(MiddleComponentData), comparerType, typeof(bool) });
                collectionMapper = (IPropertyMapper)methodInfo.Invoke(collectionProxyMapperFactory,
                                                                      new[] { _mainGenerator.GlobalCfg.EnversProxyFactory, commonCollectionMapperData, elementComponentData, _propertyValue.Comparer, embeddableElementType });
            }
            else if (genericType == typeof(GenericSetType <>))
            {
                var methodInfo = ReflectHelper.GetGenericMethodFrom <ICollectionMapperFactory>("Set",
                                                                                               type.ReturnedClass.GetGenericArguments(),
                                                                                               new[] { typeof(IEnversProxyFactory), typeof(CommonCollectionMapperData), typeof(MiddleComponentData), typeof(bool) });
                collectionMapper = (IPropertyMapper)methodInfo.Invoke(collectionProxyMapperFactory,
                                                                      new object[] { _mainGenerator.GlobalCfg.EnversProxyFactory, commonCollectionMapperData, elementComponentData, embeddableElementType });
            }
            else if (genericType == typeof(GenericListType <>))
            {
                var methodInfo = ReflectHelper.GetGenericMethodFrom <ICollectionMapperFactory>("List",
                                                                                               type.ReturnedClass.GetGenericArguments(),
                                                                                               new[] { typeof(IEnversProxyFactory), typeof(CommonCollectionMapperData), typeof(MiddleComponentData), typeof(MiddleComponentData), typeof(bool) });
                collectionMapper = (IPropertyMapper)methodInfo.Invoke(collectionProxyMapperFactory,
                                                                      new object[] { _mainGenerator.GlobalCfg.EnversProxyFactory, commonCollectionMapperData, elementComponentData, indexComponentData, embeddableElementType });
            }
            else if (genericType == typeof(GenericSortedDictionaryType <,>))
            {
                var comparerType = createGenericComparerType(type);
                var methodInfo   = ReflectHelper.GetGenericMethodFrom <ICollectionMapperFactory>("SortedMap",
                                                                                                 type.ReturnedClass.GetGenericArguments(),
                                                                                                 new[] { typeof(IEnversProxyFactory), typeof(CommonCollectionMapperData), typeof(MiddleComponentData), typeof(MiddleComponentData), comparerType, typeof(bool) });
                collectionMapper = (IPropertyMapper)methodInfo.Invoke(collectionProxyMapperFactory,
                                                                      new[] { _mainGenerator.GlobalCfg.EnversProxyFactory, commonCollectionMapperData, elementComponentData, indexComponentData, _propertyValue.Comparer, embeddableElementType });
            }
            else if (genericType == typeof(GenericMapType <,>))
            {
                var methodInfo = ReflectHelper.GetGenericMethodFrom <ICollectionMapperFactory>("Map",
                                                                                               type.ReturnedClass.GetGenericArguments(),
                                                                                               new[] { typeof(IEnversProxyFactory), typeof(CommonCollectionMapperData), typeof(MiddleComponentData), typeof(MiddleComponentData), typeof(bool) });
                collectionMapper = (IPropertyMapper)methodInfo.Invoke(collectionProxyMapperFactory,
                                                                      new object[] { _mainGenerator.GlobalCfg.EnversProxyFactory, commonCollectionMapperData, elementComponentData, indexComponentData, embeddableElementType });
            }
            else if (genericType == typeof(GenericBagType <>))
            {
                var methodInfo = ReflectHelper.GetGenericMethodFrom <ICollectionMapperFactory>("Bag",
                                                                                               type.ReturnedClass.GetGenericArguments(),
                                                                                               new[] { typeof(IEnversProxyFactory), typeof(CommonCollectionMapperData), typeof(MiddleComponentData), typeof(bool) });
                collectionMapper = (IPropertyMapper)methodInfo.Invoke(collectionProxyMapperFactory,
                                                                      new object[] { _mainGenerator.GlobalCfg.EnversProxyFactory, commonCollectionMapperData, elementComponentData, embeddableElementType });
            }
            else if (genericType == typeof(GenericIdentifierBagType <>))
            {
                var methodInfo = ReflectHelper.GetGenericMethodFrom <ICollectionMapperFactory>("IdBag",
                                                                                               type.ReturnedClass.GetGenericArguments(),
                                                                                               new[] { typeof(IEnversProxyFactory), typeof(CommonCollectionMapperData), typeof(MiddleComponentData), typeof(bool) });
                collectionMapper = (IPropertyMapper)methodInfo.Invoke(collectionProxyMapperFactory,
                                                                      new object[] { _mainGenerator.GlobalCfg.EnversProxyFactory, commonCollectionMapperData, elementComponentData, embeddableElementType });
            }
            else
            {
                if (type is CustomCollectionType)
                {
                    throw new NotImplementedException("Your custom collection type " + type.Name + " needs a defined " + typeof(ICustomCollectionMapperFactory).Name);
                }
                throw new NotImplementedException("Mapped collection type " + type.Name + " is not currently supported in Envers");
            }

            _currentMapper.AddComposite(_propertyAuditingData.GetPropertyData(), collectionMapper);
        }