Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] removing master-detail relation

I read through a previous discussion on the correct way to remove a master-detail relationship using EclipseLink.
 
Product {
 List<Characteristic> characteristics;
List<ImageInfo>imageInfos
 }
Characteristic{
Color color ;
 }

I am reusing the example , I am doing something like this to remove a 'characteristics' and its colors.
product.getCharacteristics( ).remove(characteristics);
entityManager.remove(characteristics);
 
and I am expecting the corresponding entry of 'characteristics' and color be removed from the db.
For me this works for some of the ids of 'characteristics' and dosent work for higher value of ids. Meaning it sets the foreign_key Product_id to null in characteristics tables but does not remove the relevant row from characteristic table in some cases. And I also checked that this characteristic table entry is not used/referenced in any other table. But as suggested below that sometimes the ORM is not complete and the obejct could relate to any other db object.
 
Going with the below suggestion I want to use @PrivateOwned so that orphans are removed . Now in my case tables are already existing , Can I just add the @PrivateOwned annotation and expect it to work ? or what will Ineed to do make @PrivateOwned relation to take into effect for that OneToMany relation of characteristics in Product entity. 
 
Appreciate any help/pointers towards this... Thanks!
 
*********************************
Because EclipseLink does not know, if the characteristic object is used by
any other object. In theory, EclipseLink could know this, if the ORM is
complete. But sometimes it is not complete and the object could relate to
any other database object.
Therefore you have to use the PrivateOwned annotation
 
**************************************

Back to the top