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
TraspasoAsignadoThe 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