Hello!
Again I came across something strange.
I have a Class with two elements as primary key and
Code:
public class Class1
{
private int _ID1;
private int _ID2;
private Class1 _NextClass1Object;
private Class1 _PrevClass1Object;
public virtual int ID1
{
get { return _ID1; }
set { _ID1 = value; }
}
public virtual int ID2
{
get { return _ID2; }
set { _ID2 = value; }
}
public virtual Class1 NextClass1Object
{
get { return _NextClass1Object; }
set { _NextClass1Object = value; }
}
public virtual Class1 PrevClass1Object
{
get { return _PrevClass1Object; }
set { _PrevClass1Object = value; }
}
public override bool Equals(object obj)
{
return base.Equals(obj);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
I mapped this class in this way:
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="true" namespace="HiberTest" assembly="HiberTest">
<class name="HiberTest.Class1,HiberTest" table="class1" lazy="false">
<composite-id>
<key-property name="ID1"/>
<key-property name="ID2"/>
</composite-id>
<many-to-one name="NextClass1Object" class="Class1" column="NextClass1Object"/>
<many-to-one name="PrevClass1Object" class="Class1" column="PrevClass1Object"/>
</class>
</hibernate-mapping>
With this mapping I get an error:
Quote:
Foreign key (FK1521A76764F2E76E:class1 [NextClass1Object])) must have same number of columns as the referenced primary key (class1 [ID1, ID2])
Does someone of you know how I can fix this error?
I think I have to put somehow a two element key in one column (obviously not possible).