-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Custom cascade with DeleteEventListener
PostPosted: Thu Jun 21, 2007 5:05 am 
Beginner
Beginner

Joined: Wed Apr 18, 2007 1:44 pm
Posts: 27
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.