[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[eclipselink-users] Cascade delete not desired, on a ManyToMany relation
|
Hi friends.
I'm newer on JPA, and i've started with EclipseLink 2.2 and Glassfish 3.1.1.
I have 2 entities, with a relationship ManyToMany between "patient" and
"desease", maped from a postgresql database with 3 tables (desease, patient,
patient_desase), and "patiente_desase" have a foreign key to "desase" that
restrict deletes from that table.
My problem is, when i delete a register in table "desease", is deleted on
registers in "patient_desease" too. And i don't want that behavior, i don't
want that registers on table "patient_desease" be deleted automatically.
What am I doing wrong?
These are the entities.
@Entity
@Table(name = "desease")
@XmlRootElement
public class Desease implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@NotNull
@Column(name = "code")
private Integer code;
@Size(max = 50)
@Column(name = "name")
private String name;
@JoinTable(name = "patient_desease", joinColumns = {@JoinColumn(name =
"cod_des",
referencedColumnName = "code")}, inverseJoinColumns =
{@JoinColumn(name = "cod_pat",
referencedColumnName = "code")})
@ManyToMany
private List<Patient> patientList;
....
}
@Entity
@Table(name = "patient")
@XmlRootElement
public class Patient implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@NotNull
@Column(name = "code")
private Integer code;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 40)
@Column(name = "name")
private String name;
.....
@ManyToMany(mappedBy = "deseaseList")
private List<Desease> deseaseList;
.....
}
Thank you, very much.
--
View this message in context: http://old.nabble.com/Cascade-delete-not-desired%2C-on-a-ManyToMany-relation-tp31764465p31764465.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.