-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Delete an Entry of n from a 1:n
PostPosted: Fri May 07, 2010 2:38 pm 
Newbie

Joined: Fri May 07, 2010 1:29 pm
Posts: 2
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...


Top
 Profile  
 
 Post subject: Re: Delete an Entry of n from a 1:n
PostPosted: Fri May 07, 2010 2:59 pm 
Newbie

Joined: Thu May 06, 2010 11:36 am
Posts: 5
Location: Munich, Germany
Sorry, but double posting the same issue, and that after you already got an answer to the first one, is not the finest way... (Can be avoided if you enable email notifications on topic replies.)

I already answered your question in quite detail here

_________________
There are 10 kinds of people -- those who understand binary, and those who don't


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.