title: Entity states between EJB and Jersey
body: <p>I'm a novice.</p>
  
  <p>Does Jersey and EJB hold the same EntityManager scope?</p>
  
  <p>Should I have to pass the EntityManager to EJB for same persistence context?</p>
  
  <p>The primary target usage is JTA.</p>
  
  <pre class="lang-java prettyprint-override"><code>@Stateless
  class MyEJB {
  
      public MyEntity find(Long id) {
          ...
      }
  
      @PersistenceContext;
      EntityManager entityManager;
  }
  
  
  class MyResource {
  
      @GET
      @Path("/myentity/{id}");
      public MyEntity get(@PathParam("id") final long id) {
          final MyEntity found = myEjb.find(id);
          // is found's state detached?
  
          // should I have to reattach?
          found.setDate(new Date());
  
          return found;
      }
  
      @EJB
      private MyEjb myEjb;
  
      @PersistenceContext;
      EntityManager entityManager;
  }
  </code></pre>