title: PersistentObjectException: detached entity passed to persist
body: <p>In my app I'm connected to a websocket.
  The socket is sending JSON data. As it is becoming available I process it in a different Job. In each job, I convert the JSON to a model object with GSON. There are 3 types of models, all independent, and with one common timestamp field in a MappedSuperclass. They don't have an id explicit field. I call save on the model and in 1 out of 1000 times a "PersistentObjectException: detached entity passed to persist" is thrown. </p>
  
  <p>The multiple jobs are called from a start up Job that connects to the websocket. The library I'm using creates a different thread for each incoming message. I then convert the thread into a job before saving to the database. I do this, because otherwise another PersistentObjectException is thrown about changing the id from 1 to 2 or something similar, if I allow the original thread to call save.</p>
  
  <p>I also have another job running that accesses the database at the same time. What could be wrong?</p>
  
  <pre><code>@Override
  public void onMessage(final WebSocketMessage message){
          new Job() {
              @Override
              public void doJob() {
                  processMessage(message.getText());
              }
          }.now();
  
  }
  
   public void processMessage(String message) {
          Appointment appointment = new Gson().fromJson(message, Appointment.class);
          appointment.save();
   }
  
   @Entity
   public class Appointment extends CalendarEvent {
         private String owner;
   }
  
   @MappedSuperclass
   public abstract class CalendarEvent extends Model {
         private long timestamp;
   }
  </code></pre>
  
  <p><strong>EDIT:</strong> Added some code sample</p>