168 words

OrphanRemoval not working?

2011-06-08 21:33

Dear all,

I have entities Invoice and InvoiceItem, their relation is defined:

public class Invoice implements Serializable {
    @OneToMany(mappedBy="invoice", fetch=FetchType.EAGER,
               orphanRemoval=true, cascade=CascadeType.ALL)
    private List<InvoiceItem> invoiceItemList;
public class InvoiceItem implements Serializable {
    private Invoice invoice;

I'm expecting, that removing invoiceitem from the list removes it from db, but using explorer, I can see, that the entity is still there with invoice field setted to null. When saving the entity, I'm using merge and flush. The entity object is managed, so I think this has no effect...

Is there any mistake?

Thank you


anaq's picture
Joined on 2011-06-08
User Post #3
2011-06-09 00:45

Orphan removal was not handled by ObjectDB for inverse (mapped by) collections.

Please try build 2.2.6_04 that should fix it.

Notice that usually modifications should be done on the owner side, but in the case of orphan removal the remove operation has to be done on the owned (mapped by) side to have effect (portable JPA code should update both sides anyway).

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
support's picture
Joined on 2010-05-03
User Post #347
2011-06-09 06:38

In build 2.2.6_05 is it fixed, thank you.


anaq's picture
Joined on 2011-06-08
User Post #5

Post Reply

Please read carefully the posting instructions - before posting to the ObjectDB website.

  • You may have to disable pop up blocking in order to use the toolbar (e.g. in Chrome).
  • Use ctrl + right click to open the browser context menu in the editing area (e.g. for using a browser spell checker).
  • To insert formatted lines (e.g. Java code, stack trace) - select a style in the toolbar and then insert the text in the new created block.
  • Avoid overflow of published source code examples by breaking long lines.
  • You may mark in paragraph code words (e.g. class names) with the code style (can be applied by ctrl + D).
  • Long stack traces (> 50 lines) and complex source examples (> 100 lines) should be posted as attachments.
Maximum file size: 32 MB