I am having an issue where my row is being saved twice into the database. I've found the problem occurs when I am asynchronously saving the object in two different ways.
Background:
I have a foreign key relationship lets say invoice and orders. On the invoice screen I have a grid to maintain the orders using in place editing. If I enter an order and then click the save invoice button what happens is the following
1) The row change occurs and it tries to commit the currently edited order to the database asynchronously
2) It tries to save the invoice and its orders. When I save an invoice I get an entity graph of related objects and call the savechangesasync with this list.
3) I get the callback from the order save
4) I get the callback from the invoice save
As far as I can tell this is a concurrency issue. Basically at the time of saving both items have key of -100 so they both do an insert into the table. Is there a way of blocking the second save until the first save is done? The saving is happening in a separate sandbox so I'm happy to make saves "single-threaded" within that entity manager.