You're right @Ashok, I was trying a few combinations to reproduce the error and I sent the wrong code. I uploaded two new test cases. In the unsuccessful one, I did this mapping:
@Entity
public class Team {
...
@OneToOne(mappedBy="team")
private Owner owners;
@OneToMany(mappedBy="team")
private List<Member> members;
@OneToMany(mappedBy="team")
private List<Activity> activities;
...
}
@Entity
public class Owner {
@Id
private Integer id;
@OneToOne
@JoinColumn(name = "team_id")
private Team team;
...
}
I changed the mapping of the successful one to:
@Entity
public class Team {
...
@OneToOne(mappedBy="team1")
private Owner owners;
@OneToMany(mappedBy="team")
private List<Member> members;
@OneToMany(mappedBy="team")
private List<Activity> activities;
...
}
@Entity
public class Owner {
@Id
private Integer id;
@OneToOne
@JoinColumn(name = "team_id")
private Team team1;
...
}
Renaming the variable team to team1 was enough to avoid this error. It only happens when there're a OneToOne and a OneToMany relationship mapping to the same name. |