7 Replies Latest reply: Mar 15, 2012 12:20 AM by Ashish Vashisht RSS

    How to use createItem via DataServiceTransaction-API correctly

    Flavy85 Community Member

      Hello,

       

      I try to create an item via the DataServiceTransaction-API:

       

      DataServiceTransaction dtx = DataServiceTransaction.begin(false);

      dtx.setSendChangesToAdapter(true);

       

      EntityA a = new EntityA();

      EntityB b = new EntityB();

      a.setEntityB(b);

       

      dtx.createItem(EntityA.class.getName(), a);

      dtx.commit();

       

      When I call this serivce from my FlexClient an error occurred, wich says that EntityB is unsaved!

       

      I know why this erro happens but really dont't know how to fix that.

       

      Is there any way to make the creation cascading(from the modeler-plugin within FlashBuilder)?

       

      or

       

      Do i have to create the "child"-properties on my own via another call of "dtx.createItem" with EntityB? If so, how can I check the DataService for the entity, if the entity already exists? via a fill operation? how do call that manually?

             

      I know question over question!

       

      Hope you can help me out!

       

      Cheers

      Flavy