Is this possible?
The table I'm mapping has a composite key consisting of 4 columns. I'm coding against a legacy database, and there is no way the organization is going to allow changes to the very ungortunate database design.
Mapping the table goes fine, in this manner (using .Net attributes)
[CompositeId(1)]
[KeyProperty(2, Name = "CrossRefNo", TypeType = typeof(Int32))]
[Column(3, Name = "crossrefno", NotNull = true)]
[KeyProperty(4, Name = "FromObjId1", TypeType = typeof(Int32))]
[Column(5, Name = "fromobjid1", NotNull = true)]
[KeyProperty(6, Name = "ToObjId1", TypeType = typeof(Int32))]
[Column(7, Name = "toobjid1", NotNull = true)]
[KeyManyToOne(8, Name = "CrossRefType", Class = "CrossReferenceType")]
[Column(9, Name = "crossreftype")]
But using this class in a List, from another NHibernate mapping Class seems problematic, as all documentation seems to indicate that List needs a unique key
<list name="MessageList" cascade="all">
<key column="ConversationId"/>
<index column="`Order`"/>
<one-to-many
class="UniDirectional.Message, NHibernateOneToMany"/>
</list>
What I need is a way to define a List within a NHibernate mapping class, that has a composite foreign key. Is this possible? Anyone found a way around this problem?
|