nhibernate / fluentの具象マッピングごとにテーブルを取得して、データベースステートメントを発行してクラスのタイプを判別し、次に、大規模な左結合uberステートメントですべてのサブクラステーブルを結合するのではなく、詳細について別のステートメントを発行することは可能ですか?
つまり、サブクラスの詳細を「遅延」ロードできます。
流暢なnhibernateおよびClassMap/SubClassMapマッピングクラスを使用してマッピングされたクラス階層があります。各派生クラス(とにかくそれらのほとんど)には独自のテーブルがあります。つまり、具体的なクラスごとのテーブルです。
すべてのサブクラスが同じテーブルに含まれている場合に使用されるため、識別子の値は指定していません。ただし、基本クラステーブルには、それがどのタイプであるかを示す整数値があります。nhibernateはこのデータを使用し、派生クラスデータに対して遅延ロードを発行できますか?識別子の値は、基本クラスの列挙型に対応するデータベース内の整数です。
例。
public sealed class PartyMap : ClassMap<Party>
{
public PartyMap()
{
Table("Party");
// I thought this might do it, but it doesn't :-(
Polymorphism.Explicit();
Id(x => x.Id).Column("PartyId");
Map(x => x.PartyType).CustomType<PartyType>().Column("PartyTypeId");
Map( ...
// if I specify this, nhibernate expects all the fields
// to be in the base class table, above Table(...) is the only one used.
// DiscriminateSubClassesOnColumn<int>("PartyTypeId", 0).AlwaysSelectWithValue();
}
}
public class PersonMap : SubclassMap<Person>
{
public PersonMap()
{
Table("Person");
KeyColumn("PartyId");
// if I specify this, nhibernate expects all the fields
// to be in the base class table, above Table(...) is ignored.
// DiscriminatorValue((int) PartyType.Person);
}
}