Buonasera a tutti,
ho il seguente problema:
Ho la classe Step
e la classe Notify:codice:@Entity @Table(name = "STEP") public class Step implements Identifiable { @Id @Column(name = "ID") private long id; @OneToMany(orphanRemoval = true, cascade = ALL, mappedBy = "notifyPK") private Collection<Notify> notifications; ... }
che ha una chiave composta.codice:@Entity @Table(name = "NOTIFY") public class Notify implements Serializable { @EmbeddedId private NotifyPK notifyPK; ... }
La chiave composta di Notify è NotifyPK che l'ho realizzata così:
Quando eseguo i miei test che vanno a creare le tabelle ed inserire dei dati, viene lanciata un'eccezione(riporto messaggio più significativo):codice:@Embeddable public class NotifyPK implements Serializable { @Column(name = "ID_RECEIVER") private String idReceiver; @Column(name = "ID_STEP") private Long idStep; public boolean equals(Object obj) { ... } public int hashCode() { ... } }
Exception Description: An incompatible mapping has been encountered between [class test.Step] and [class test.Notify]. This usually occurs when the cardinality of a mapping does not correspond with the cardinality of its backpointer.
Naturalmente è un problema di mapping per le chiavi composte infatti, inizialmente avevo realizzato Notify con chiave singola e non avevo nessun problema.
Qualcuno mi sa dire dove sbaglio?
P.S. naturalmente ID_STEP è referenziato ad ID ma ID_RECEIVER a chi lo devo referenziare?
ringrazio
nk

Rispondi quotando



