私の基本クラスのマッピング:
<class name="BaseClient,BackOffice.Core" table="client" polymorphism="explicit" >
<id name="Id" unsaved-value="0" type="int">
<column name="id" not-null="true"/>
<generator class="hilo">
<param name="max_lo">0</param>
<param name="where">table_name = 'clients'</param>
</generator>
</id>
<property name="Name" >
<column name="name" length="1024"/>
</property>
その子のマッピング
<joined-subclass name="Client, Transport.Core" table="transport_client" extends="BaseClient, BackOffice.Core">
<key column="Id"/>
</joined-subclass>
BaseClient を含むマッピング クラス
<class name="BankPayment, BackOffice.Core" table='bank_payment'>
<id name="Id" unsaved-value="0" type="int">
<column name="id" not-null="true"/>
<generator class="native"/>
</id>
<many-to-one name="ClientSource" class="BaseClient,BackOffice.Core" column="client_source_id" cascade="none"/>
そして今クエリ:
ICriteria criteria = NHibernateSession.CreateCriteria(typeof(BankPayment));
criteria.SetFetchMode(BankPayment.Properties.ClientSource, FetchMode.Join);
だから私はこのSQLを取得します
FROM bank_payment this_
left outer join client baseclient2_ on this_.client_source_id=baseclient2_.id
left outer join transport_client
私の質問は、なぜ2番目のSQLを取得するのか、どうすればそれを回避できるのかです。明示的なポリモーフィズムが役立つと思いますが、2 番目の結合があります。ありがとう