1- First you need to map the entity Pupil
@Entity
@Table(name="Aluno") // Eu sempre informo o 'name', mania minha
public class Aluno implements Serializable {
@Id
@Column(name = "id")
private java.lang.Long id;
// Demais campos...
}
2 - Mapping Entity Appraisal
@Entity
@Table(name="Avaliacao")
public class Avaliacao implements Serializable {
@Id
@Column(name = "id")
private java.lang.Long id;
// Demais campos...
}
3 - Mapping the entity Rating
Before posting the example, it is not always necessary to map these Many-to-Many. I decided to map it because it has information (Which I believe is the student’s grade).
@Entity
@Table(name="NotaAvaliacaoAluno")
public class NotaAvaliacaoAluno implements Serializable {
@Id
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn( name = "avaliacaoId", referencedColumnName="id")
private Avaliacao avaliacao;
@Id
@Column(name = "alunoId")
@JoinColumn(name = "alunoId", referencedColumnName="id")
private Aluno aluno;
// Demais campos...
}
4 - Now we return to the student class and include
@OneToMany(fetch=fetchType.LAZY, mappedBy="aluno")
private List<NotaAvaliacaoAluno> notasValiacaoAlunoList;
Ready.
P.S.: As I do not know your model I believe the most appropriate and analyze my response, understand what I suggested and adapt to your case.