OrphanRemoval not working?

#1

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 {
...
    @ManyToOne
    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

Michael

#2

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
#3

In build 2.2.6_05 is it fixed, thank you.

Michael

Reply