Hi, I'm new with Hibernate and i got a problem with relationshiop one-to-one.
How I do a relationship with two-way using one-to-one? My code:
Family Member.hbm.xml:Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="SISP.Domain.FamilyMember, SISP.Domain" table="FamilyMember" dynamic-update="true">
<id name="User" column="UserId">
<generator class="foreign">
<param name="property">User</param>
</generator>
</id>
<version name="_version" unsaved-value="0" access="field" column="_version" />
<many-to-one name="Family" class="SISP.Domain.Family, SISP.Domain" foreign-key="FK_FamilyMember_Family" cascade="save-update" fetch="join">
<column name="FamilyId" />
</many-to-one>
<many-to-one name="User" class="SISP.Domain.User, SISP.Domain" foreign-key="FK_FamilyMember_User" cascade="save-update">
<column name="UserId" />
</many-to-one>
<property name="Ocupation" type="String">
<column name="Ocupation" length="70" />
</property>
</class>
</hibernate-mapping>
Note the column
UserId is duplicated, but I need this because I want UserId is a one-to-one from
User and I want to get the user from
FamilyMember and i put the other column too, but I got this error:
"Invalid Index n for this SqlParameterCollection with Count=n"How I do a Relationship one-to-one of 2 ways?