3 Replies Latest reply on Jan 27, 2007 1:05 PM by gavin.king

    Getting "Entity not managed" when using EntityManager in ses

    liudan2005

      My EntityManager is injected to my session scoped and I have 3 methods:

      @PersistenceContext(type = EXTENDED)
      private EntityManager em;
      
      public String list(){
      ...
      }
      
      public String edit(){
      ...
      }
      
      public String save(){
      ...
      }
      


      In list method, I retrieve a collection of data from db. in edit(), I start to edit for a single entity. in save(), when I try to use em.persist(myentity) or em.merge(myentity). I get java.lang.IllegalArgumentException: Entity not managed.

      If I change my ejb to conversation scoped, the problem would disappear. Any idea?