NHibernate では、クラスとそのマッピングを定義します。複合キーの定義と equals/GetHashCode が正しいかどうかわかりません。
[DataMember]
public virtual int EXCEPTION_ID { get; set; }
[DataMember]
public virtual int RUNID { get; set; }
[DataMember]
public virtual int ROW_ID { get; set; }
[DataMember]
public virtual string FIELD_NAME { get; set; }
[DataMember]
public virtual string FIELD_VALUE { get; set; }
public override bool Equals(object obj)
{
if (obj == null)
{
return false;
}
var t = obj as ExceptionFld;
if ((EXCEPTION_ID == t.EXCEPTION_ID) && (RUNID == t.RUNID) && (ROW_ID == t.ROW_ID) && (FIELD_NAME == t.FIELD_NAME))
{
return true;
}
return false;
}
public override int GetHashCode()
{
return (EXCEPTION_ID + "|" + RUNID + "|" + ROW_ID + "|" + FIELD_NAME).GetHashCode();
}
マッピングファイルは
<composite-id>
<key-property name="EXCEPTION_ID"/>
<key-property name="RUNID"/>
<key-property name="ROW_ID"/>
<key-property name="FIELD_NAME"/>
</composite-id>
<property name="EXCEPTION_ID" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" not-null="true">
<column name="EXCEPTION_ID" />
</property>
<property name="RUNID" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" not-null="true">
<column name="RUNID" />
</property>
<property name="ROW_ID" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" not-null="true">
<column name="ROW_ID" />
</property>
<property name="FIELD_NAME" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" not-null="true">
<column name="FIELD_NAME" />
</property>
<property name="FIELD_VALUE" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" not-null="true">
<column name="FIELD_VALUE" />
</property>