I've found a lot of questions about this but they did not solve my problem.
This is the structure that I'm trying to map:
TABLE A
col0 (PK) | colA (PK) | colB
TABLE B
col0 (PK) |colA (PK) | colC (PK) | ColD
TABLE C
col0 (PK) | colA (PK) | colC (PK) | ColE (PK) | ColF
I have a problem on the third table (Table C). The exception thrown is
org.hibernate.MappingException: Repeated column in mapping for entity: TableC column: colA (should be mapped with insert="false" update="false")
Table C:
@Entity
@Table(name="TableC")
public class TableC implements Serializable{
@EmbeddedId
private TableCId tableCId;
@MapsId("tableBId")
@ManyToOne
@JoinColumns({
@JoinColumn(name="col0", referencedColumnName="col0"),
@JoinColumn(name="colC", referencedColumnName="colC"),
@JoinColumn(name="colA", referencedColumnName="colA")
})
private TableB tableB;
// Getters and setters
}
Here I defined the TableCId
@Embeddable
public static class TableCId implements Serializable{
private TableBId tableBId;
private Integer colE;
// Getters and setters
// equals and hashcode
}
And then the TableBId
@Embeddable
public static class TableBId implements Serializable{
private Integer col0;
private Integer colA;
private Integer colC;
// Getters and setters
// equals and hashcode
}
I already tried to put insertable=false, updatable=false
in @JoinColumn but with no result.