private final <T> void setValue(int index, Field<T> field, T value) { Value<T> val = getValue0(index); UniqueKey<?> key = getPrimaryKey(); // Normal fields' changed flag is always set to true if (key == null || !key.getFields().contains(field)) { val.setValue(value); } // The primary key's changed flag might've been set previously else if (val.isChanged()) { val.setValue(value); } // [#2764] Users may override updatability of primary key values else if (updatablePrimaryKeys(settings(this))) { val.setValue(value); } // [#2698] If the primary key has not yet been set else if (val.getOriginal() == null) { val.setValue(value); } // [#979] If the primary key is being changed, all other fields' flags // need to be set to true for in case this record is stored again, an // INSERT statement will thus be issued else { val.setValue(value, true); if (val.isChanged()) { changed(true); } } }
@Override public final void changed(String fieldName, boolean changed) { changed(indexOrFail(fieldsRow(), fieldName), changed); }
@Override public final void changed(Field<?> field, boolean changed) { changed(indexOrFail(fieldsRow(), field), changed); }