-->
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.  [ 2 posts ] 
Author Message
 Post subject: onPostInsertEvent differences between and onPostUpdateEvent
PostPosted: Thu May 11, 2006 4:50 pm 
Newbie

Joined: Mon Mar 13, 2006 7:07 pm
Posts: 8
can anyone explain this to me?

If I modify an entity during a "onPostInsertEvent" the change gets propagated to the database.

If I modify an entity during a "onPostUpdateEvent" the change does NOT get propagated to the database.

Example:


Code:
   public void onPostInsert(PostInsertEvent event)
   {   
      if(event.getEntity() instanceof Client)
      {
         Client client = (Client) event.getEntity();
         Note note = new Note();
         note.setNote("Client Added.");
         note.setDate(new Date());
         client.getNotes().add(note);
      }
   }

   public void onPostUpdate(PostUpdateEvent event)
   {
      if(event.getEntity() instanceof Client)
      {   
         Client client = (Client) event.getEntity();
         Note note = new Note();
         note.setNote("Client Updated.");
         note.setDate(new Date());
         client.getNotes().add(note);   
      }
   }


The onPostInsertEvent adds the Note to the database.
The onPostUpdateEvent gets fired, but no Note is added.

Can someone please explain the differences between these two behaviours? And explain how I can modify an entity during an update event?


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 12, 2006 8:40 am 
Newbie

Joined: Mon Mar 13, 2006 7:07 pm
Posts: 8
bump


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

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.