Hi all
I have the following mapping.
Code:
<class name="Request" table="Request">
<composite-id>
<key-property name="C_CPR_NO" />
<key-property name="RECEIVED" />
<key-property name="REQUEST_NO" />
</composite-id>
<property name="HEADLINE" />
<property name="SOURCE" />
<property name="REQ_TYPE" />
<property name="STATUS" />
</class>
<class name="ReferralData" table="REFERRAL_DATA">
<composite-id>
<key-property name="C_CPR_NO" column="C_CPR_NO"/>
<key-property name="REFERRAL_DATE" column="REFERRAL_DATE"/>
<key-property name="REFERRAL_NO" column="REFERRAL_NO" />
</composite-id>
<property name="DEADLINE" type="Date" />
<many-to-one name="REQUEST" class="Request">
<column name="C_CPR_NO"/>
<column name="REQUEST_RECEIVED"/>
<column name="REQUEST_NO"/>
</many-to-one>
</class>
c# code
Code:
public class ReferralData
{
public virtual string C_CPR_NO { get; set; }
public virtual DateTime REFERRAL_DATE { get; set; }
public virtual int REFERRAL_NO { get; set; }
public virtual char REF_ACTIVE_FLAG { get; set; }
public virtual int REFERRER_TYPE_NO { get; set; }
public virtual DateTime DEADLINE { get; set; }
public virtual Request REQUEST { get; set; }
}
request = new Reqeust();
referralData = new ReferralData();
referralData.REQUEST = Request;
session.save(referralData);
I get the following exception:
{"could not insert: [SQL: INSERT INTO REFERRAL_DATA (DEADLINE, C_CPR_NO, REQUEST_RECEIVED, REQUEST_NO, C_CPR_NO, REFERRAL_DATE, REFERRAL_NO) VALUES (?, ?, ?, ?, ?, ?, ?)]"}
{"ORA-00957: duplicate column name\n"}
How should I write the mapping to get past this error? I don't want nhibernate to insert or update C_CPR_NO twice. And C_CPR_NO is part of the primary key and the many-to-one mapping.
/Hans