I have an entity like this, and I am failing on mapping the ID column of the second_table to chId of my entity, but in the case of dep_id mapping works fine
Stacktrace is:
nested exception is org.hibernate.MappingException: Repeated column in mapping for entity: com.example.entity.ClientData column: id
@Data
@Entity
@Table(name = "first_table")
@SecondaryTable(name = "second_table")
public class ClientData {
@Id
@NotNull
private String id;
// Id from 2nd table
@Column(name = "id", table = "second_table")
private String chId;
@Column(name = "dep_id", table = "first_table")
private String depId;
@Column(name = "dep_id", table = "second_table")
private String chDepId;
}
What am I doing wrong ?
Adding
insertable = false, updatable = falsesolved the problem, ID from other tables mapped exactly as I wanted