The best example i can foud to explain my problem i found it in the hibernate test.
Code:
public class ClassWithCompositeId
{
private Id _id;
private int _oneProperty;
public ClassWithCompositeId(){}
public ClassWithCompositeId(Id id )
{
_id = id;
}
public Id Id
{
get {return _id;}
}
public int OneProperty
{
get {return _oneProperty;}
set {_oneProperty = value;}
}
}
Code:
public class Id
{
private string _keyString;
private short _keyShort;
private System.DateTime _keyDateTime;
public Id() {}
public Id(string keyString, short keyShort, System.DateTime keyDateTime) {
_keyString = keyString;
_keyShort = keyShort;
_keyDateTime = keyDateTime;
}
public string KeyString {
get { return _keyString;}
set { _keyString = value;}
}
public System.DateTime KeyDateTime {
get { return _keyDateTime;}
}
public override int GetHashCode() {
return _keyString.GetHashCode();
}
public override bool Equals(object obj) {
Id otherObj = obj as Id;
if(otherObj==null) return false;
if(otherObj.KeyString.Equals(this.KeyString)) return true;
return false;
}
}
What attribute i have to put to have the righ mapping. My goal is to have this kind of file
Code:
<class
name="NHibernate.Test.CompositeId.ClassWithCompositeId, NHibernate.Test"
table="class_w_com_id"
>
<composite-id name="Id" class="NHibernate.Test.CompositeId.Id, NHibernate.Test" access="nosetter.camelcase-underscore">
<key-property name="KeyString" column="string_" type="String(20)" length="20" />
<key-property name="KeyShort" column="short_" access="field.camelcase-underscore"/>
<key-property name="KeyDateTime" column="date_" type="DateTime" access="nosetter.camelcase-underscore"/>
</composite-id>
<property name="OneProperty" column="one_property"/>
</class>