Code:
Entity(name = "Assignment")
class Assignment {
@Id
private int id;
private String assignmentCode;
}
Entity(name = "Review")
class Review {
@Id
private int id;
private String assignmentCode;
}
I have 2 tables each with 2 columns as above. I want to create a list of reviews in the assignment entity and these reviews are joined on the column assignmentCode.
In the Assignment, I defined as below :
Code:
@OneToMany(targetEntity = Review.class, fetch=FetchType.EAGER)
@JoinColumn(name="assignmentCode")
private List<Review> reviews = new ArrayList<Review>();
but when I retrieve Assignment assignment = session.findById(Assignment.class, id); I'm getting the exception Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Ambiguous column name 'assignmentCode'
What's the correct to define the reviews collection? I cannot change the table structures to have different column names.