Hi all,
is it safe to do something like:
Code:
class ParentListener extends DefaultDeleteEventListener {
void onDelete(DeleteEvent event) {
if (event.getObject() instanceof Parent) {
Parent parent = (Parent) event.getObject();
for (Child child : parent.getChildren) {
childDAO.delete(child)
}
}
super.onDelete(event);
}
}
this is to implement custom children cascade delete (I can't model this as a cascaded association from some specific reasons). I tried with Pre and PostDelete event listeners, but both raise exceptions about unsafe thread access to the session or something like that (I haven't the backtrace just right now). But the above seems to work. In short, is it safe to reenter the session from event listeners? Or at least, is it safe for some of them?
Thank you in advance.
Cheers,
Carlos