Hi,
I get a QueryException "path expression ends in a composite value" when trying :
Code:
// Parent parent is already instancied
string hql = "From Child child Where child.Parent=:parent";
IQuery q = Session.CreateQuery(hql);
q.SetEntity("parent", parent);
IList llist = qq.List();
My Parent.hbm.xls contains ...
Code:
<composite-id name="Id" class="Domaine.ParentId, Domaine">
<key-property name="Name" type="String">
<column name="Name" sql-type="varchar" not-null="true" />
</key-property>
<key-property name="LastName" type="String" >
<column name="LastName" sql-type="String" not-null="true" />
</key-property>
</composite-id>
My Child.hbm.xls contains ...
Code:
<many-to-one name="Parent" class="Domaine.Parent, Domaine" >
<column name="Name" sql-type="varchar" not-null="true"/>
<column name="LastName" sql-type="varchar" not-null="true"/>
</many-to-one>
My ParentId class...
Code:
public class ParentId
{
private string _name;
private string _surName;
public virtual string Name
{
get { return _name; }
set { _name = value; }
}
public virtual string SurName
{
get { return _surName; }
set { _surNAme = value; }
}
public override bool Equals(object obj)
{
ParentId otherObj = obj as ParentId ;
if (otherObj == null)
{
return false;
}
if (otherObj.Name.Equals(this.Name)
&&
otherObj.SurName.Equals(this.SurName))
{
return true;
}
else
{
return false;
}
}
public override int GetHashCode()
{
return Name.GetHashCode() ^ SurName.GetHashCode();
}
}
Thank's