2009-08-04 6 views
0

Kann mir jemand sagen, wie man dieses Mapping mit Fluent NHibernate durchführt? Es ist einfach eine Kontentabelle mit einem zusammengesetzten Schlüssel, der viele untergeordnete Konten in einer Konjunktionstabelle hat.Wie kann ich eine sich selbst referenzierende n: n-Beziehung im Fluent-NHibernate-Mapping erstellen?

Hier ist die Arbeits NHibernate-Mapping und das Erstellen von SQL erzeugt sie:

<?xml version="1.0"?> 
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true"> 
<class name="NHibernateM2M000.Account, NHibernateM2M000" lazy="false"> 
    <composite-id> 
     <key-property type="Int32" name="AccountId" /> 
     <key-property type="Char" name="AccountTypeAbbr" /> 
    </composite-id> 
    <property name="Name" column="AccountName" /> 
    <bag name="ChildAccounts" lazy="false" table="AccountXref"> 
     <key> 
      <column name="ParentAccountId" sql-type="int" /> 
      <column name="ParentAccountTyper" sql-type="nchar" length="1" /> 
     </key> 
     <many-to-many class="NHibernateM2M000.Account, NHibernateM2M000"> 
      <column name="ChildAccountId" sql-type="int"/> 
      <column name="ChildAccountType" sql-type="nchar" length="1" />    
     </many-to-many> 
    </bag> 
</class> 

create table Account (AccountId INT not null, AccountTypeAbbr NCHAR(1) not null, AccountName NVARCHAR(255) null, primary key (AccountId, AccountTypeAbbr)) 

create table AccountXref (ParentAccountId int not null, ParentAccountTyper nchar not null, ChildAccountId int not null, ChildAccountType nchar not null) 

alter table AccountXref add constraint FKB769F8B52F1320AB foreign key (ChildAccountId, ChildAccountType) references Account 

alter table AccountXref add constraint FKB769F8B5A2DB3DC7 foreign key (ParentAccountId, ParentAccountTyper) references Account 

Antwort

0

ich nach einem Blick auf Fluent NHibernate im Zeitpunkt dieser Veröffentlichung und jetzt glauben, dass es nicht möglich ist . In die .hbm-Datei zu gelangen, ist der einzige Weg, um das zu erreichen, was ich hier wollte.

Verwandte Themen