I'm working with a legacy database where FK's aren't always used.
For example I have an entity Person and an entity Country. A person has a Country which is mapped as a many-to-one in the Person mapping.
<many-to-one name="Country" class="Country" foreign-key="none" lazy="false" not-found="ignore" fetch="join" outer-join="true" column="countryid"/>
When person has null
as column value (countryid) it won't perform an extra select query (because it knows that there won't be a reference in the country table), but when a person has 0
as column value NH will perform another select to check the country tabel wether the country actually doesn't exist. But because we do a left outer join, NH should already know that it doesn't exist.
Just to clarify, if a the column has a value of 1
and it is present in the country table, it will not perform an extra select.
Is there anyway to tell NHibernate not to do the extra select query?
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…