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?