title: Entity must be managed to call remove
body: <p>What's going on here?</p>
  
  <pre class="lang-java prettyprint-override"><code>@Stateless
  @LocalBean
  public class AppointmentCommentDao {
      public void delete(long appointmentCommentId) {
          AppointmentComment ac = em.find(AppointmentComment.class, appointmentCommentId);
          if (ac != null)
          {
              em.merge(ac);
              em.remove(ac);
          }
      }
      @PersistenceContext
      private EntityManager em;
  }
  </code></pre>
  
  <p>On the call to <code>remove</code> I get an <code>IllegalArgumentException</code> with the message being <code>Entity must be managed to call remove: ...., try merging the detached and try the remove again.</code></p>