How to force NHibernate to always do a join for many-to-one -
nhibernate rather smart , omits joins on many-to-one if fields related entity not used in query. however, want formula discriminator on other table without subselect, did custom persister with
protected override string discriminatorformulatemplate { { return this.discriminatorformula; } }
and specified column name in formula (but column name related table)
<discriminator formula="typeid" />
i understand prone name conflicts, in specific case not problem.
so want force related (many-to-one
) table joined main one. best way this? joined times, when hn detects fields used, not know how force time.
<many-to-one ... fetch="join"/>
this covers get, criteria , lazy load, not hql.
another option using custom sql operations, , select subquery instead of table (with join inside query)
unfortunately, @ point hack. way nh designed, discriminator must in same table.
Comments
Post a Comment