Esempio n. 1
0
  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);
      }
    }
  }
Esempio n. 2
0
 @Override
 public final Result<O> fetchParents(Collection<? extends R> records) {
   if (records == null || records.size() == 0) {
     return new ResultImpl<O>(new DefaultConfiguration(), key.getFields());
   } else {
     return fetch(records, key.getTable(), key.getFieldsArray(), getFieldsArray());
   }
 }