have a many-to-many relationship which is implemented as
bidirectional.
public class SegmentGroup
{
    public virtual long Id { get; protected set; }
    public virtual string SegmentGroupName { get; set; }
    public virtual IList<Segment> Segments { get; set; }
}

and
public class Segment
{
    public virtual long Id { get; protected set; }
    public virtual string SegmentName { get; set; }
    public virtual IList<SegmentGroup> SegmentGroups { get; set; }
}

I am using the automapping feature with the following conventions:
....
 .ForTypesThatDeriveFrom<SegmentGroup>(m1 => m1.HasManyToMany(x =>
x.Segments)
                                      .WithTableName
("SegmentGroupSegments")
                                      .Cascade.All()
                                      .WithParentKeyColumn
("SegmentGroupId")
                                      .WithChildKeyColumn
("SegmentId"))
.ForTypesThatDeriveFrom<Segment>(m1 => m1.HasManyToMany(x =>
x.SegmentGroups)
                                      .WithTableName
("SegmentGroupSegments")
                                      .Cascade.All()
                                      .Inverse()
                                      .WithParentKeyColumn
("SegmentGroupId")
                                      .WithChildKeyColumn
("SegmentId"))
....
The tables are generated correctly, however there is no PK at ALL
(would prefer the combined PK, don't want a surrogate PK)
in the link table. Is that so by design? If yes, how do I at least
set
UNIQUE constraint on
the combination of the 2 FKs?
Here are the generated hbms:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-
access="">
  <class name="Fintexx.STAR.DataContract.SegmentGroup,
Fintexx.STAR.DataContract, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null" table="`SegmentGroup`" xmlns="urn:nhibernate-
mapping-2.2">
    <id name="Id" type="Int64" column="SegmentGroupId">
      <generator class="identity" />
    </id>
    <property name="SegmentGroupName" type="String">
      <column name="SegmentGroupName" />
    </property>
    <bag name="Segments" cascade="all" table="SegmentGroupSegments">
      <key column="SegmentGroupId" />
      <many-to-many column="SegmentId"
class="Fintexx.STAR.DataContract.Segment, Fintexx.STAR.DataContract,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
    </bag>
  </class>
</hibernate-mapping>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-
access="">
  <class name="Fintexx.STAR.DataContract.Segment,
Fintexx.STAR.DataContract, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null" table="`Segment`" xmlns="urn:nhibernate-
mapping-2.2">
    <id name="Id" type="Int64" column="SegmentId">
      <generator class="identity" />
    </id>
    <property name="SegmentName" type="String">
      <column name="SegmentName" />
    </property>
    <bag name="SegmentGroups" cascade="all" inverse="true"
table="SegmentGroupSegments">
      <key column="SegmentId" />
      <many-to-many column="SegmentGroupId"
class="Fintexx.STAR.DataContract.SegmentGroup,
Fintexx.STAR.DataContract, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null" />
    </bag>
  </class>
</hibernate-mapping>
THX,
Darko
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to