Buonasera a tutti,
ho il seguente problema:
Ho la classe Step
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;
...
}
e la classe Notify:
codice:
@Entity
@Table(name = "NOTIFY")
public class Notify implements Serializable {
@EmbeddedId
private NotifyPK notifyPK;
...
}
che ha una chiave composta.
La chiave composta di Notify è NotifyPK che l'ho realizzata così:
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() {
...
}
}
Quando eseguo i miei test che vanno a creare le tabelle ed inserire dei dati, viene lanciata un'eccezione(riporto messaggio più significativo):
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