cyr2005 wrote:
hi ,
i have this error:
org.hibernate.MappingException: Repeated column in mapping for entity: model.Child_TC column: ac_id (should be mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:504)
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:542)
I think it cause because i want tu add a PrimaryKey/ForignKey in a table Child_Tc two field childtc and fathertc who are 2 FK of ac_id identifiant of a table AC, then there are a repetition of column but it's normal i want to do that with SQL :
CREATE TABLE CHILDTC(child_tc_id integer NOT NULL,
father_tc_id integer NOT NULL,
channel_number integer,
constraint constcfchild foreign key(child_tc_id) references AC(ac_id),
constraint constcfkfather foreign key(father_tc_id) references AC(ac_id),
PRIMARY KEY (father_tc_id, child_tc_id)
);
the code of child_tc.hbm.xml are :
<hibernate-mapping>
<class name="model.Child_TC" table="CHILD_TC">
<composite-id name="compositeID" class=" model.Child_TC">
<key-many-to-one name="child_tc_id" class="model.AC" column="ac_id"
/>
<key-many-to-one name="father_tc_id" class="model.AC" column="ac_id"
/>
</composite-id>
<property name="channel_number" type="int">
<column name="channel_number" sql-type="int" not-null="true"/>
</property>
</class>
</hibernate-mapping>
thanks u ,
Hibernate version: 3.0
Mapping documents: 3.0
Name and version of the database you are using: oracle 8.1
All that it's asking you to do is specify - insert="false" update="false" - on one of the mappings so that when it goes to update the column in the database, there's no confusion which java attribute the value comes from.