I\'m trying to switch out .hbm
mappings to fluent mappings and have a problem with the mapping of composite-ids and the usage of Interfaces
the Class lo
Tanks! But I've found the answer on my on. In fact i found a missing feature in fluent nHibernate. The feature has already been added to the dev branch by Paul Batum.
You would use it like so:
Map {
public ClassWithCompositeIdMap() {
CompositeId()
.KeyReference(x => x.KeyOne, k =>
k.Type<KeyOneImplementation>(), "colkeyone")
.KeyReference(x => x.KeyTwo, k =>
k.Type<KeyTwoImplementation>(), "colkeytwo");
...
}
}
http://github.com/paulbatum/fluent-nhibernate/tree/dev
You can see the original Conversation here: http://support.fluentnhibernate.org/discussions/help/349-how-to-map-a-composite-id-when-using-interfaces-or-how-to-change-the-class-attribute-in-the-key-many-to-one-tag
Try downloading NhGen from SourceForge. It reads database schemas and generates Fluent mappings and classes etc. While all the code might not be what you need, it should start you off in the right direction as it supports composite keys and represents them as separate classes off the main entity.
I beleive it uses a syntax similar to
CompositeId()
.ComponentCompositeIdentifier(x => x.Key, "Namespace.Key, Assembly")
.KeyProperty(x => x.Key.Id1, "Id1")
.KeyProperty(x => x.Key.Id2, "Id2")
.KeyProperty(x => x.Key.Id3, "Id3");