2
My question is whether I can use the annotation @ID
several times in a row, if this is possible or if there is another way to reference attributes of the type ID after the first.
import javax.persistence.Entity;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "t_Turma")
class Turma {
@Id
private int id_Professor;
@Column(name = id_Disciplina)
private int id_Disciplina;
@Column(name = id_Quadrimestre)
private int id_Quadrimestre;
@Column
private int id_Turma;
@Column
private String plano;
public int getId_Turma(){
return this.id_Turma;
}
public void setId_Turma(int id_Turma){
this.id_Turma = id_Turma;
}
public String getPlano(){
return this.plano;
}
public void setPlano(String plano){
this.plano = plano;
}
}
If I understand correctly. Are these ids in the same entity foreign keys? If so, you need to make relationships with the tags Many to Many, One to Many and One to One. In the JPA documentation you will find this detailed information.
– Edson Camargo