Hi,
i ope you guys can help me out.
if have a OneToMany-ManyToOne Association.
The N-Elements are Stored in a List<Object>.
My Problem now is, when i remove an Element of the List and save the Object with Persit, it doesn't remove the Entity in the Table.
If i make a refresh on the first object i find the removed Element back in the List again.
Does anyone knows how to solve this Problem?
Her is my code sofar:
Code:
Bestellung:
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "BID", nullable = false)
private Integer bid;
@Basic(optional = false)
@Column(name = "Datum", nullable = false)
@Temporal(TemporalType.DATE)
private Date datum;
@Column(name = "Zeit")
@Temporal(TemporalType.TIME)
private Date zeit;
@ManyToOne
@JoinColumn(name = "MAID", nullable = false)
private PMitarbeiter mitarbeiter;
@ManyToOne
@JoinColumn(name = "KID", nullable = false)
private PKunde kunde;
@OneToMany(mappedBy="bestellung", cascade=CascadeType.ALL)
private List<PBestellDetails> details;
Code:
BestellDetails:
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "ID", nullable = false)
private Integer id;
@ManyToOne
@JoinColumn(name = "BID", nullable = false)
private PBestellungen bestellung;
@ManyToOne
@JoinColumn(name = "ABID", nullable = false)
private PArtikel artikel;
@Column(name = "Menge")
private Integer menge;
@Column(name = "Status")
private String status;
@Column(name = "Liefertermin")
@Temporal(TemporalType.DATE)
private Date liefertermin;
and i remove like that
Code:
bestellung.getDetails().remove(0); // remove the first entry of the List
ormapper.persist(bestellung);
after the persists the remvoed entry is still in the mySQL Database...