title: Is it possible to persist new Entities in a @Pre/PostPersist Listener?
body: <p>I am trying to setup my hibernate application to persist a new <code>Notification</code> entity everytime an <code>Activity</code> Entity is created - at the moment, everything i have tried the <code>Notification</code> just fails to persist silently (no errors in the logs but sql is never executed).</p>
  
  <p>Can anyone confirm that it is even possible to persist additional entities in the Hibernate pre/postPersist listeners?</p>
  
  <p>I have read in the documentation:</p>
  
  <blockquote>
    <p>A callback method must not invoke EntityManager or Query methods!</p>
  </blockquote>
  
  <p>But I have read several other discussion threads that seem to indicate that it is possible.</p>
  
  <p>For reference, the two approaches I have attempted are:</p>
  
  <ol>
  <li><p><code>@PrePersist</code> method - setting a cascade.ALL relationship between <code>Activity</code> and <code>Notification</code>, and in the PrePersist method simply creating a new <code>Notification</code> and linking it to the <code>Activity</code> being created in a hope that the <code>Notification</code> would be persisted.</p></li>
  <li><p><code>@PostPersist</code> method - using <code>@Configurable</code> and a ListenerClass, wiring in a service and creating a new <code>Notification</code> entity and then explicitly calling the entityManger persist</p></li>
  </ol>
  
  <p>Can someone confirm what I am trying is possible?</p>