#update to answer all 3 questions:
Question 1:
For a new record, the flush() sends it to the backend, then removes it once the flush completes, and then the refresh() brings it back down if is part of the defining request.
Question 2/3:
When working with parent/child objects in the offline data store, make sure that any updates you perform are done against the "__metadata/uri" field of the object.
Basically what happens with the SAP Kapsel Offline OData store is:
- When you post new data to the offline store, it creates in internal ID/URI which represents the location of this data in the offline store (you see if it if you look at the "__metadata/uri" of the object/response).
- Any updates must be made to this object or else the context may get lost when flush happens. PATCH/MERGE/PUT to the metadata uri. You may have to include the etag as a parameter also (this is also in the __metadata).
Example using batch:
batchChanges.push(oModel.createBatchOperation(uri,"PATCH", oEntry,{sETag: etag}));
If you do the updates in this manner, it should work ok. The SMP handles the mapping of the response to the offline data using the URI/ETAG metadata, so multiple changes should work properly.
I have found though that sometimes it gets confused if you try to change the key fields as part of the POST. (See Kapsel Offline OData - Flush works, but doesn't clear sap.islocal() for more details).