I have two table Student and Student_Pseudo.
A Pseudo can be attributed for one or more Student.
Student contains
* Student_code
* Student_login
Student_Pseudo contains
* Stu_code
* Pseudo
Stu_code is a foreign key of Student_code
I want to get Pseudo in Student Entity using @ManyToOne relation and it's not working
@ManyToOne(optional = false)
@JoinColumn(name="STU_CODE", referencedColumnName="STUDENT_CODE", nullable=false)
private Pseudo pseudo;
The Pseudo is always null when I get Students !!!
I finally found the solution based on @Chris response. Thanks to everyone for your help.
@ManyToOne(optional = false)
@JoinTable(
name = "Student_Pseudo",
joinColumns = @JoinColumn(name = "STU_CODE", nullable=false),
inverseJoinColumns = @JoinColumn(name="STU_CODE", nullable=false))
private Pseudo pseudo;