Hi, first of all i'm quite new to NHibernate.
i have this problem with a legacy database.
first let see,
I have a table "Address" with the following fields:
Address
--------
id (pk)
ownertype (varchar)
ownerid (int)
addr1 (varchar)
add2 (varchar)
postcode (int)
...
and i might have other tables that has one-to-many relationship with the table above.
e.g: a table user might have multiple address related to its one row. and there might be another table that has same relationship. how to differentiate them is by putting discriminator value in the field "ownertype"
for now, i'm using mapping like below:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Entities" namespace="Entities">
<class name="address" table="Address" where="STATUS != 'D'">
<id name="ID" column="ADDID">
<generator class="identity"/>
</id>
<any name="OWNER" id-type="System.Int32" meta-type="System.String">
<meta-value class="user" value="enUser"/>
<meta-value class="org" value="enOrg"/>
<column name="OWNERTYPE" />
<column name="OWNERID" />
</any>
<property name="ADDR1" />
<property name="ADDR2" />
</class>
</hibernate-mapping>
i can add entity "address" into entity "user" or "org" child just fine, and it works well in saving. but when i tried to access the address property, it give me error "The given key was not present in the dictionary"
Did I do the mapping correctly?
how do i solve this.
thanks for the help