3 Replies Latest reply on Jun 8, 2007 8:13 AM by Pete Muir

    Persistence Question

    Mihai Anescu Newbie

      Hi, I have this situation:

      I have a Seam generated application (so I use lots of the generated code)

      I enter on the edit screen of entity B from the list.
      B has a combo box of entity A. Near this combo box there is a link that sends me to the edit screen of the instance of A (A1) that is referred in the instance of B (B1).
      I placed an attribute on entity A (transient) and on the edit screen, a combo box that allows me to create a new instance of A.
      So, the flow would be this:
      If I check the checkbox, I must "clone" A1 into A2, insert A2 into the DB, update B1.setA( A2 ), then update it into the DB.
      If i don't check the box, then update A1.

      I do this in the AHome class, in the update method:

      public String update()
       A a= getInstance();
       B b = bHome.getInstance();
       if( a.isSaveAsNew() )
       A newA = a.duplicate();
       return persist();
       return super.update();

      But, the problem is that A1 also gets updated, and I don't want this to happen. I read on the forum something about FlushType.MANUAL. But I don't start a conversation, so what else can I do?

      I tried different methods, even to set the newA as the instance, but always a gets updated.

      Anyone, any idea?