7 Replies Latest reply on Dec 18, 2008 3:23 PM by Rodrigo Souto

    why ejb function is trying to flush?

    Rodrigo Souto Newbie

      I am using Seam 2.1.1.CR1, Jboss AS 4.2.3, seam managed persistence context and a seam transaction manager (ejb-transaction).


      I am on a long running conversation (A stateful EJB with flushMode MANUAL)


      On a conversation I get a persistence object: for example a person that has a relationship with orders (1..n)





      @Begin(join=true, flushMode=FlushModeType.MANUAL)
      public String createOrder() {
      ...
      Person p = entityManager.createQuery("from Person where id=1").getSingleResult();
      Order o = new Order();
      p.getOrder().add(o);
      o.setPerson(p);
      ...
      return "orderPage.xhtml";
      }
      





      orderPage.xhtml contains an ajax button that calls a method in the same conversation, that uses the same injected entityManager and runs a query, for example:



      @Begin(join=true, flushMode=FlushModeType.MANUAL)
      public void pressButton() {
      entityManager.createQuery("from Person").getResultList();
      }
      



      The problem is that when I press the button I am getting a TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing;


      I know that person is dirty (on JPA) with an unsaved transient instance (order), but my question is: why pressButton is trying to flush if is on MANUAL mode?