-->
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.  [ 8 posts ] 
Author Message
 Post subject: Repeated column in mapping for entity
PostPosted: Fri Mar 03, 2006 3:01 pm 
Newbie

Joined: Fri Mar 03, 2006 2:36 pm
Posts: 4
Hibernate version: 3.1
SGBD: Oracle

Table one
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
  "-//Hibernate/Hibernate Mapping DTD//EN"
  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping>
  <class
    name="Evento"
    table="EVENTO"
  >

    <id
    name="id"
    type="integer"
    column="NRO_EVENTO"
  >
      <generator class="sequence">
        <param name="sequence">S_NRO_EVENTO</param>
      </generator>
    </id>

. . .

  <set name="evRelatos" table="EV_RELATO" inverse="true" lazy="true" cascade="all-delete-orphan">
    <key column="NRO_EVENTO"/>
    <one-to-many class="EvRelato"/>
  </set>

</class>
</hibernate-mapping>


Table two
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
  "-//Hibernate/Hibernate Mapping DTD//EN"
  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping>
  <class
    name="EvRelato"
    table="EV_RELATO"
  >

  <id name="id" column="NRO_EVENTO" type="integer">
        <generator class="Evento">
            <param name="property">nroEvento</param>
        </generator>
    </id>

. . .

      <many-to-one
        name="NroEvento"
        column="NRO_EVENTO"
        class="Evento"
      >
      </many-to-one>

  </class>
</hibernate-mapping>



error in mapping:
Code:
INFO Configuration:1057 - processing foreign key constraints
Exception in thread "main" org.hibernate.MappingException: Repeated column in mapping for entity: EvRelato column: NRO_EVENTO (should be mapped with insert="false" update="false")


The tables cannot be modified


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 03, 2006 3:14 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
try changing your ID...column="<somethingelse>"...in your EvRelato class

_________________
-JT

If you find my replies helpful, please rate by clicking 'Y' on them. I appreciate it.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 03, 2006 3:36 pm 
Newbie

Joined: Fri Mar 03, 2006 2:36 pm
Posts: 4
but the key of table two also calls NRO_EVENTO and is the foreign key of table one


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 03, 2006 3:47 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
santoro wrote:
<many-to-one
name="NroEvento"
column="NRO_EVENTO"
class="Evento"
>


Your <many-to-one specifies column=NRO_EVENTO - that will be the FK that is in your EV_RELATO table.

You have: EVENTO (1)-(M) EV_RELATO, therefor you need the NRO_EVENTO (as FK) in the EV_RELATO table, but you are declaring the ID of EV_RELATO to be NRO_EVENTO - thus the duplicate column.

_________________
-JT

If you find my replies helpful, please rate by clicking 'Y' on them. I appreciate it.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 03, 2006 3:53 pm 
Newbie

Joined: Fri Mar 03, 2006 2:36 pm
Posts: 4
It forgives, I did not understand which it would be the solution, as would be the mapping?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 03, 2006 4:10 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
Sorry, I don't understand your comments...

_________________
-JT

If you find my replies helpful, please rate by clicking 'Y' on them. I appreciate it.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 03, 2006 4:18 pm 
Newbie

Joined: Fri Mar 03, 2006 2:36 pm
Posts: 4
what it must be modified?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 03, 2006 4:21 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
Quote:
try changing your ID...column="<somethingelse>"...in your EvRelato class

(and in your table def for evRelato.)

_________________
-JT

If you find my replies helpful, please rate by clicking 'Y' on them. I appreciate it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.