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.  [ 4 posts ] 
Author Message
 Post subject: Repeated column in mapping for entity
PostPosted: Fri Aug 12, 2005 8:55 am 
Beginner
Beginner

Joined: Thu Aug 11, 2005 11:16 am
Posts: 20
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

_________________
Cyril,


Top
 Profile  
 
 Post subject: Re: Repeated column in mapping for entity
PostPosted: Fri Aug 12, 2005 9:08 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
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.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 12, 2005 9:13 am 
Beginner
Beginner

Joined: Thu Aug 11, 2005 11:16 am
Posts: 20
i have add insert and update in my hbm code like that :
<key-many-to-one name="child_tc_id" class="model.AC" column="ac_id"
insert="false" update="false"/>

and i have this error :

org.xml.sax.SAXParseException: Attribute "insert" must be declared for element type "key-many-to-one".

and if i remonve insert , i have the same error for update and if a remonve update i have the next error !! :)

_________________
Cyril,


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 12, 2005 9:17 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
cyr2005 wrote:
i have add insert and update in my hbm code like that :
<key-many-to-one name="child_tc_id" class="model.AC" column="ac_id"
insert="false" update="false"/>

and i have this error :

org.xml.sax.SAXParseException: Attribute "insert" must be declared for element type "key-many-to-one".

and if i remonve insert , i have the same error for update and if a remonve update i have the next error !! :)


Ok, that's telling you that insert= isn't allowed for <key-many-to-one> elements so my advice wasn't pertinent.

I think there's an issue with your mapping. You can't have a composite-key point to the same Column - 'ac_id' twice. It doesn't make any sense.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


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

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.