Is it possible to create new entity in Pre or PostUpdateListener? I see that my listener is being called, but creating entity has no effect on database.
Example
class MyListener implements PreUpdateListener
{
public boolean onPreUpdate(PreUpdateEvent event)
{
if (event.getEntity() instanceof Dog == false)
return false;
LogEntry e = new LogEntry();
e.setText("Entity of class " + event.getEntity.getClass() + " updated.");
event.getPersister().getFactory().getCurrentSession().persist(e);
return false;
}
}
So when any Dog is updated new log entry should be created. But it doesn't work this way - log entry isn't persisted, although no exception is thrown. Is it forbidden to create new entities in pre/post update listeners?
// Edit:
sorry for double post, network problems :/
|