asolfre / objectify-appengine

Automatically exported from code.google.com/p/objectify-appengine
MIT License
0 stars 0 forks source link

Implement delete orphans #204

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
It would be nice to have possibility to delete orphans just like hibernate does.

public class Author
{
    @Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
    List<Book> books;
}

Scenario:
1. we create Author entity with book1, book2
2. we update book2, add book3 and removes book1
3. objectify will deletes book1  automatically - so I do not have to do it 
manually

Note:
If this will not be implemented, then it would be great to add global 
notifications for OnSave, OnLoad (not per entity which is already implemented). 
Something like:

public interface OnSaveNotification {
  void notify(Class entity);
} 

public interface OnLoadNotification {
  void notify(Class entity);
}

ofy.addOnSaveNotification(new CustomOnSaveNotification());

so I would be able to implement it by myself globally.

Original issue reported on code.google.com by pohorele...@gmail.com on 2 Jun 2014 at 5:19

GoogleCodeExporter commented 9 years ago
This kind of cascading delete is really hard to do without a transaction that 
can span the entire group, and GAE transactions are limited to 5 entity groups. 
I'll leave the enhancement request here, but I wouldn't expect it to be 
implemented anytime soon.

Original comment by lhori...@gmail.com on 3 Oct 2014 at 5:59