-->
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: org.hibernate.MappingException: Repeated column in mapping
PostPosted: Wed May 11, 2011 6:27 pm 
Beginner
Beginner

Joined: Fri Jun 23, 2006 6:40 pm
Posts: 25
Dear Members

I am working with the follow dependencies

Code:
     <dependency>
         <groupId>org.hibernate</groupId>
         <artifactId>hibernate-core</artifactId>
         <version>3.3.2.GA</version>
      </dependency>
      <dependency>
         <groupId>org.hibernate</groupId>
         <artifactId>hibernate-annotations</artifactId>
         <version>3.3.1.GA</version>
      </dependency>
      <dependency>
         <groupId>org.hibernate</groupId>
         <artifactId>hibernate-commons-annotations</artifactId>
         <version>3.3.0.ga</version>
      </dependency>
      <dependency>
         <groupId>javassist</groupId>
         <artifactId>javassist</artifactId>
         <version>3.6.0.GA</version>
      </dependency>


Among many entities I have these two Asignado and TraspasoAsignado

The first defined in this way

Quote:
@Entity
@Table(name="asignado")
public class Asignado implements Serializable{

private static final long serialVersionUID = 1L;

private String idAsignado;

....

public Asignado(){}

@Id
public String getIdAsignado() {
return idAsignado;
}


public void setIdAsignado(String idAsignado) {
this.idAsignado = idAsignado;
}


The Second

Quote:
@Entity
@Table(name="traspasoasignado")
public class TraspasoAsignado implements Serializable{

private static final long serialVersionUID = 1L;

....

@Id
public String getIdTraspasoAsignado() {
return idTraspasoAsignado;
}


...


@OneToOne
@JoinColumn(name="idAsignado")
public Asignado getAsignadoOrigen() {
return asignadoOrigen;
}

public void setAsignadoOrigen(Asignado asignadoOrigen) {
this.asignadoOrigen = asignadoOrigen;
}

@OneToOne
@JoinColumn(name="idAsignado")
public Asignado getAsignadoDestino() {
return asignadoDestino;
}

public void setAsignadoDestino(Asignado asignadoDestino) {
this.asignadoDestino = asignadoDestino;
}


I get this error

Code:
Caused by: org.hibernate.MappingException:
Repeated column in mapping for entity:
  com.jordan.manuel.domain.TraspasoAsignado column: idAsignado
  (should be mapped with insert="false" update="false")

OK, is clear that idAsignado is repetead

I already did a research on the forum and the most common solution is do

Code:
@JoinColumn(name="idAsignado", insertable=false, updatable=false)


but I did realize the follow

Even if I use insertable=false and updatable=false I will have one column that you could not write to or update to; if that so, then, when hibernate it's retrieving the data how it will know which property to fill, with only one column for 2 properties.

edited from
viewtopic.php?f=1&t=1003903&view=next (last reply)

I want get the follow row representation

Asignado
PK
Asg1 ...
Asg2 ...
Asg3 ...

TraspasoAsignado
PK
Tr1 .. Asg1 Asg2 ...
Tr2 .. Asg10 Asg22 ...
Tr3 .. Asg15 Asg50 ...

Obviously each FK value for idAsignado in TraspasoAsignado entity never must be the same

How I could resolve this?

Thanks in advanced

_________________
kill your pride, share your knowledge with all


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.