-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: many-to-one on compsite key with a part in the primary key.
PostPosted: Fri Oct 03, 2008 10:49 am 
Newbie

Joined: Fri Sep 26, 2008 12:12 pm
Posts: 2
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.