we use the following code to save data ( autosave is false ).
- Code: Select all
databaseManager.startTransaction()
<pre-save code>
if (!databaseManager.saveData()) {
_thePressedButton = plugins.dialogs.showErrorDialog('Error in first Save', 'See log', 'OK');
_failedArray = databaseManager.getFailedRecords()
for (var j = 0; j < _failedArray.length; j++) {
_record = _failedArray[j];
plugins.Log.error('Error <xxxxxxx>: ' + _record.exception);
}
<handle error>
databaseManager.rollbackEditedRecords()
databaseManager.rollbackTransaction()
return -1
}
<post-save code>
if (!databaseManager.saveData()) {
_thePressedButton = plugins.dialogs.showErrorDialog('Error in second Save', 'See log', 'OK');
_failedArray = databaseManager.getFailedRecords()
for (var j = 0; j < _failedArray.length; j++) {
_record = _failedArray[j];
plugins.Log.error('Error <xxxxxxx>: ' + _record.exception);
}
<handle error>
databaseManager.rollbackEditedRecords()
databaseManager.rollbackTransaction()
return -1
}
if (!databaseManager.commitTransaction()) {
_thePressedButton = plugins.dialogs.showErrorDialog('Error in commit', 'See log', 'OK');
_failedArray = databaseManager.getFailedRecords()
for (var j = 0; j < _failedArray.length; j++) {
_record = _failedArray[j];
plugins.Log.error('Error <xxxxxxx>: ' + _record.exception);
}
<handle error>
databaseManager.rollbackEditedRecords()
databaseManager.rollbackTransaction()
return -1
}
else {
return 0
}
sometimes a user gets an error message " 'Error in commit' " but when we look in the log file there
are no entries of failed records.
If we check the database, everything that the user edited is saved perfectly.
The only way I can reproduce this is by commenting the startTransaction.
In that case there is a commitTransaction without a startTransaction.
I the get the same error and no lines in the log.
How can this happen (the code above always starts the transaction and the startTransaction command has no return code.
Regards,