Hello fellow nhibernate enthusiasts,
I recently started working with nhibernate and like most people here ive come across a fair share of problems. My latest problem is a mstery to me and I could use some help with it.
I will try give a short summary.
I have a parent class with a bag mapping (rest omitted)
Code:
<bag name="Waardes" lazy="false">
<key column="RegelID"/>
<one-to-many class="DocumentBodyregelWaarde,
BusinessObjects"/>
</bag>
and the mapping for the 'bagged' class:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="DocumentBodyregelWaarde,
BusinessObjects"
table="DocumentBodyRegelWaarde">
<id name="ID" column="ID">
<generator class="native"/>
</id>
<property name="RegelID" column="RegelID"/>
<property name="DocumentID" column="DocumentID"/>
<property name="Regeltype" column="RegelType"/>
<property name="Volgorde" column="Volgorde"/>
<property name="XMLveldnaam" column="XMLVeldnaam"/>
<property name="XMLveldwaarde" column="XMLVeldwaarde"/>
</class>
</hibernate-mapping>
The situation i was trying to create here is that when i load a entity of the parent class, it would load the child class.
This actually works. But with a twist. When i look up the created SQL in NhibernateProfiler, it shows the following:
Code:
SELECT waardes0_.RegelID as RegelID1_,
waardes0_.ID as ID1_,
waardes0_.ID as ID18_0_,
waardes0_.RegelID as RegelID18_0_,
waardes0_.DocumentID as DocumentID18_0_,
waardes0_.RegelType as RegelType18_0_,
waardes0_.Volgorde as Volgorde18_0_,
waardes0_.XMLVeldnaam as XMLVeldn6_18_0_,
waardes0_.XMLVeldwaarde as XMLVeldw7_18_0_
FROM DocumentBodyRegelWaarde waardes0_
WHERE waardes0_.RegelID = 17038240 /* @p0 */
As can be seen, 2 of the properties are requested twice. But I have no idea why, i've tried for a different mapping with set, but this results in the same query. Also an outer-join results in the two properties being requested twice.
Is the problem staring me in the face, or should i look for the problem elsewhere?