One customer was having a big problem with duplication of records (Violation of PRIMARY KEY constraint), when trying to add any purchase request via their HCPms offline native app for Android. For some reason, the device was not receiving an acknowledge from the backend saying that the flushed data had been committed. So, when another operation in the offline store was performed and a flush was called again, the duplication error happened again, because, for the offline store, the first purchase request had not been committed to the backend yet.
The reason behind this issue was incorrect understanding of how to properly setup and code for offline OData. The documentation provided was somewhat vague and has been improved due to this finding. For now, you can refer to the HCPms documentation which is very well explained: SAP HANA Cloud Platform Mobile Services. Please, remember that some other error would also have happened for an online app.
Different rewrite modes require different service root URLs in SMP and HCPms. The customer had set the Rewrite Mode field of the connection to the backend configuration to the Rewrite URL on Backend value, but had set the serviceRoot option of the OData Offline Store Options as if they had set the Rewrite Mode field of the connection to the backend configuration to the Rewrite URL on HANA Mobile Server value. Remember that the serviceRoot property of an offline store options structure identifies the root of an OData service.
OK, so let's understand what is the correct value for each Rewrite Mode option:
NOTE: "To enable applications using an external back end to run offline, you must select one of the rewrite options."
In Java code, the store options would look like the following for the Rewrite URL on Backend option:
ODataOfflineStoreOptions options = new ODataOfflineStoreOptions();
...
options.host = "myserver";
options.port = "8080";
options.serviceRoot = "http://myserver:8080/sap/opu/odata/sap/service";
...
In Java code, the store options would look like the following for the Rewrite URL on HANA Mobile Server option:
ODataOfflineStoreOptions options = new ODataOfflineStoreOptions();
...
options.host = "myserver";
options.port = "8080";
options.serviceRoot = "http://myserver:8080/<ApplicationID>";
...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
13 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |