1
To create this table you need instead an object that contains an Id for an entity (Embeddedid). For example:
@Embeddable
public class ExamesCadastradosPK {
@ManyToMany
@JoinColumn(name="EXCA_EXAM_ID", referencedColumnName="EXAM_ID")
private Exame exame;
@ManyToMany
@JoinColumn(name="EXCA_CLIE_ID", referencedColumnName="CLIE_ID")
private Cliente cliente;
// getters e setters
}
This object has the two keys of the table that wants to merge, but it is not an entity. Note the @Embeddable annotation. Now create an object that uses this Embeddable as the primary key:
@Entity
@Table(name="exames_cadastrados")
public class ExamesCadastrados {
@EmbeddedId
private ExamesCadastradosPK examesCadastradosPK;
// getters e setters
}
your question was a little superficial, I couldn’t quite understand your problem/doubt
– Brumazzi DB
then Brumazzi, I have a table in the database called exames_registered, with the key Idexame referencing the table exam the key idCliente referencing the table client, idExame and idCliente in the table exames_registered are foreign keys that form a composite primary key, and when I have the class created from these settings in the bank, it gives that error above.. wanted to know how to proceed when a relationship is n to n.. how to do this in JPA?
– Higor Senna
I believe you will have to create the class manually, by the alert, it seems that JPA does not have support to do the merge.
– Brumazzi DB