private final int delete0() { TableField<R, ?>[] keys = getPrimaryKey().getFieldsArray(); try { DeleteQuery<R> delete1 = create().deleteQuery(getTable()); Utils.addConditions(delete1, this, keys); if (isExecuteWithOptimisticLocking()) { // [#1596] Add additional conditions for version and/or timestamp columns if (isTimestampOrVersionAvailable()) { addConditionForVersionAndTimestamp(delete1); } // [#1547] Try fetching the Record again first, and compare this // Record's original values with the ones in the database else { checkIfChanged(keys); } } int result = delete1.execute(); checkIfChanged(result, null, null); return result; } // [#673] If store() is called after delete(), a new INSERT should // be executed and the record should be recreated finally { changed(true); } }
private final int delete0() { TableField<R, ?>[] keys = getPrimaryKey().getFieldsArray(); try { DeleteQuery<R> delete1 = create().deleteQuery(getTable()); Tools.addConditions(delete1, this, keys); if (isExecuteWithOptimisticLocking()) { // [#1596] Add additional conditions for version and/or timestamp columns if (isTimestampOrVersionAvailable()) { addConditionForVersionAndTimestamp(delete1); } // [#1547] Try fetching the Record again first, and compare this // Record's original values with the ones in the database // [#5384] Do this only if the exclusion flag for unversioned records is off else if (isExecuteWithOptimisticLockingIncludeUnversioned()) { checkIfChanged(keys); } } int result = delete1.execute(); checkIfChanged(result, null, null); return result; } // [#673] [#3363] If store() is called after delete(), a new INSERT should // be executed and the record should be recreated finally { changed(true); fetched = false; } }
private final int storeUpdate0(TableField<R, ?>[] keys) { UpdateQuery<R> update = create().updateQuery(getTable()); addChangedValues(update); Utils.addConditions(update, this, keys); // Don't store records if no value was set by client code if (!update.isExecutable()) return 0; // [#1596] Set timestamp and/or version columns to appropriate values BigInteger version = addRecordVersion(update); Timestamp timestamp = addRecordTimestamp(update); if (isExecuteWithOptimisticLocking()) { // [#1596] Add additional conditions for version and/or timestamp columns if (isTimestampOrVersionAvailable()) { addConditionForVersionAndTimestamp(update); } // [#1547] Try fetching the Record again first, and compare this // Record's original values with the ones in the database else { checkIfChanged(keys); } } // [#1596] Check if the record was really changed in the database int result = update.execute(); checkIfChanged(result, version, timestamp); if (result > 0) { changed(false); } return result; }
checkIfChanged(keys); checkIfChanged(result, version, timestamp);