Seguinte a tabela e essa
ALUNOS
@Entity
public class Alunos implements Serializable {
@Id
//@GeneratedValue(strategy = GenerationType.IDENTITY)
@GeneratedValue
@Column(name = "id_aluno")
private Integer idAluno;
@Column(name = "nome")
private String nome;
@Column(name = "email")
private String email;
@Column(name = "telefone")
private String telefone;
@Column(name = "endereco")
private String endereco;
@Column(name = "sexo")
private String sexo;
@Column(name = "dt_nasc")
@Temporal(TemporalType.DATE)
private Date dtNasc;
@Column(name = "peso")
private double peso;
@Column(name = "altura")
private double altura;
@JoinColumn(name = "id_modalidade", referencedColumnName = "id_modalidade")
@ManyToOne(optional = false, fetch = FetchType.LAZY)
private Modalidades idModalidade;
@Entity
public class InstrutorModalidade implements Serializable{
@Id
@GeneratedValue
@Column(name = "id")
private Integer id;
@Column(name = "periodo")
private String periodo;
@JoinColumn(name = "id_modalidade", referencedColumnName = "id_modalidade")
@ManyToOne(optional = false, fetch = FetchType.LAZY)
private Modalidades idModalidade;
@JoinColumn(name = "id_instrutor", referencedColumnName = "id_instrutor")
@ManyToOne(optional = false, fetch = FetchType.LAZY)
private Instrutores idInstrutor;
QUERO FAZER UM INNER JOIN COM ESSE SELECT USANDO CriteriaBuilder
SELECT a., im. FROM Alunos a INNER JOIN instrutor_modalidade im on (a.id_modalidade = im.id_modalidade)
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Alunos> c = cb.createQuery(Alunos.class);
Root<Alunos> aluno = c.from(Alunos.class);
Join<Alunos, InstrutorModalidade> join = aluno.join("id_modalidade", JoinType.INNER);
c.equals(join.get("id_modalidade"));
TypedQuery q = em.createQuery(c);
q.getResultList();
Alguem pode me ajudar?