Is it possible to assemble a list in a class with only a few objects?
@NamedQuery(name = "Curso.Aprovados", query = "select cur from Classificacao cl JOIN cl.candidato ca JOIN ca.curso cur")
public class Curso {
@Id
@Column(name = "id")
private int id;
@OneToMany(fetch = FetchType.LAZY)
private List<Candidato> candidatoList;
...
}
public class Candidato {
@Id
@Column(name = "id")
private Integer idCa;
@JoinColumn(name = "id_curso", referencedColumnName = "id")
@ManyToOne(optional = false, cascade = CascadeType.DETACH)
private Curso curso;
...
}
public class Classificacao {
@Id
@Column(name = "id")
private int id;
@OneToOne
@JoinColumn(name = "id_candidato", referencedColumnName = "id")
private Candidato candidato;
...
}
I would like the candidate list in the course class to only contain the candidates that have a rating, in case that Select contemplates what I need, I just do not know how to load those candidates into the course list.
select cur from Classificacao cl JOIN cl.candidato ca JOIN ca.curso cur
Thank you very much