I have 3 classes - Issue, Sprint and EmbeddableId class SprintId.
I don't know how to achieve having jiraInstance field both in Issue and Sprint class. As Issue may not be connected to any Sprint I want to have jiraInstance java field on Issue to track in which jira instance this particular issue was created. When its connected to Sprint I want to just have jiraInstance as part of its composite key. But below mapping gives me:
Caused by: org.hibernate.DuplicateMappingException: Table [issue] contains physical column name [jira_instance] referred to by multiple logical column names: [jira_instance], [jiraInstance]
classes:
class Issue {
@ManyToOne()
@JoinColumns({
@JoinColumn(
name = "sprint_id",
referencedColumnName = "sprint_id"),
@JoinColumn(
name = "jira_instance",
referencedColumnName = "jira_instance")
})
private Sprint lastSprint;
//this field causes clash with 'jira_instance' in @JoinColumn
private String jiraInstance;
}
class Sprint {
@EmbeddedId
private SprintId id;
}
class SprintId implements Serializable {
@Column(name = "sprint_id")
private String sprintId;
@Column(name = "jira_instance")
private String jiraInstance;
}
Adding @Column as:
@Column(name="jira_instance")
private String jiraInstance;
cause hibernate to claim that it has to be insertable = true, updatable = false, but I need to be able to add jiraInstance to Issue when its not connected to any sprint.