orphanRemoval = true not working when CascadeType.REMOVE is disabled

#1

Dear all,

I have entities Employee and Address, their relation is defined (full example in attachment):

@Entity
    public static class Employee {
....
        @OneToMany(orphanRemoval = true)
        private Set<Address> addresses;

I'm expecting, that removing Employee from db, addresses has been too, but I can see, that the Address is still:

[Address{name='name_1'}, Address{name='name_2'}, Address{name='name_3'}, Address{name='name_4'}, Address{name='name_5'}]
Employee{id=1, addresses=[Address{name='name_2'}, Address{name='name_4'}, Address{name='name_5'}]}
After commit :
[Address{name='name_1'}, Address{name='name_2'}, Address{name='name_3'}, Address{name='name_4'}, Address{name='name_5'}]
null
Employee{id=2, addresses=[Address{name='name_2'}, Address{name='name_3'}]}

I'm try use 

@OneToMany(cascade = CascadeType.REMOVE)

Address entities used Employee (id=1) deleted, but Address (name_2) using other Employee (id=2) deleted too:

[Address{name='name_1'}, Address{name='name_2'}, Address{name='name_3'}, Address{name='name_4'}, Address{name='name_5'}]
Employee{id=1, addresses=[Address{name='name_2'}, Address{name='name_4'}, Address{name='name_5'}]}
After commit :
[Address{name='name_1'}, Address{name='name_3'}]
null
Employee{id=2, addresses=[Address{name='name_2'}, Address{name='name_3'}]}

Is there any mistake?

Thank you

 

#2

Thank you for your report and for the test case that demonstrates the bug.

Build 2.5.6_05 should fix it.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

Post Reply

To post a reply and/or subscribe to update notifications - please login