title: Using JPA entity listeners to persist JPA entities
body: <p>I have the following method in a JPA EntityListener:</p>
  
  <pre><code>@PostPersist
      void onPostPersist(Pli pli) {
          EvenementPli event = new EvenementPli();
          event.setPli(pli);
          event.setDateCreation(new Date());
          event.setDateEvenement(new Date());
          event.setType(TypeEvenement.creation);
          event.setMessage("Création d'un pli");
          event.persist();
      }
  </code></pre>
  
  <p>Basically, I am trying to create an event by persisting an instance of <code>EvenementPli</code> each time an instance of the <code>Pli</code> entity is persisted.</p>
  
  <p>The trouble is that the by the time <code>event.persist();</code> is called the Pli row is not in the database which causes Mysql to complain about the constraint...</p>
  
  <p>Can anyone please help?</p>