title: Hibernate session thread safety
body: <p>I know that sessions are not thread safe.  My first question: is it safe to pass an entity to another thread, do some work to it, then pass it back to the original thread and update.</p>
  
  <pre><code>public class Example1 {
      MyDao dao;
      ...
      public void doWork() {
          MyEntity entity = dao.getEntity();
          Runnable job = new Job(entity);
          Thread t = new Thread(job);
          t.run();
          t.join();
          dao.merge(entity);
      }
  
  }
  </code></pre>
  
  <p>My second question: is it safe to new up an entity in one thread and save it in another?</p>
  
  <pre><code>public class Example2 {
      MyDao dao;
      ...
      public void doWork() {
          MyEntity entity = new Entity();
          new Thread(new Job(dao, entity)).run();
      }
  }
  
  public class Job implements Runnable {
      private MyDao dao;
      private MyEntity entity;
      ...
      @Override
      public void run() {
          dao.save(entity);
      }
  }
  </code></pre>
  
  <p><strong>Edit</strong> I forgot to mention that the entities are specifically configured for eager loading</p>