Hi all
I don't know where to go with this problem. I'm trying to integrate NH
4.0.2 into our project, which is using NH 3.3.0 today. It fails. I went
debugging into the code and found the reason why.
This mapping:
Bag(
x => x.AssignedInstruments,
m =>
{
m.Table("SomeTable");
m.Key(k => k.Column("Some_FK"));
},
r => r.ManyToMany(m =>
{
m.Class(typeof(InstrumentEntity));
m.Column("Instrument_FK");
}));
Goes through this code (ModelMapper.cs, Line 1278):
protected virtual ICollectionElementRelationMapper
DetermineCollectionElementRelationType(MemberInfo property, PropertyPath
propertyPath, System.Type collectionElementType)
{
// ...
//NH-3667 & NH-3102
//check if property is really a many-to-many: as detected by
modelInspector.IsManyToMany and also the collection type is an entity
if (modelInspector.IsManyToMany(property) == true)
{
if (property.GetPropertyOrFieldType().IsGenericCollection()
== true)
{
var args =
property.GetPropertyOrFieldType().GetGenericArguments();
if (modelInspector.IsEntity(args.Last()) == true)
{
return new ManyToManyRelationMapper(propertyPath,
customizerHolder, this);
}
}
}
The problem in our project is that the entity is not known at compile time
of the mapping by code definition, because is it mapped using XML (which
also cannot be changed because of problems with mapping by code not able to
map that, but this is another problem). The XML mappings are not visible to
mapping by code, so IsEntity returns false and it turns the many to many
relation into a bag of primitive values. In version 3.3, it was always
creating a correct many-to-many mapping.
I do not understand this bugfix. Why should it *ever *be correct to make a
many-to-many relation a collection of primitive values?
Both related bugs are about dictionaries. Could it probably be fixed
somewhere else, in dictionary specific code?
Cheers
Stefan
--
---
You received this message because you are subscribed to the Google Groups
"nhibernate-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.