To create this table you must first have 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 both table keys that you want to join, 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
}