final int storeInsert(final Field<?>[] storeFields) { final int[] result = new int[1]; delegate(configuration(), (Record) this, INSERT) .operate(new RecordOperation<Record, RuntimeException>() { @Override public Record operate(Record record) throws RuntimeException { result[0] = storeInsert0(storeFields); return record; } }); return result[0]; }
final Collection<Field<?>> setReturningIfNeeded(StoreQuery<R> query) { Collection<Field<?>> key = null; if (configuration() != null) if (!TRUE.equals(configuration().data(DATA_OMIT_RETURNING_CLAUSE))) // [#1859] Return also non-key columns if (TRUE.equals(configuration().settings().isReturnAllOnUpdatableRecord())) key = Arrays.asList(fields()); // [#5940] Getting the primary key mostly doesn't make sense on UPDATE statements else if (query instanceof InsertQuery || updatablePrimaryKeys(settings(this))) key = getReturning(); if (key != null) query.setReturning(key); return key; }
final void getReturningIfNeeded(StoreQuery<R> query, Collection<Field<?>> key) { if (key != null && !key.isEmpty()) { R record = query.getReturnedRecord(); if (record != null) { for (Field<?> field : key) { int index = indexOrFail(fieldsRow(), field); Object value = record.get(field); values[index] = value; originals[index] = value; } } // [#1859] In some databases, not all fields can be fetched via getGeneratedKeys() if (TRUE.equals(configuration().settings().isReturnAllOnUpdatableRecord()) && REFRESH_GENERATED_KEYS.contains(configuration().family()) && this instanceof UpdatableRecord) ((UpdatableRecord<?>) this).refresh(key.toArray(EMPTY_FIELD)); } }
/** * Set an updated timestamp value to a store query */ final Timestamp addRecordTimestamp(StoreQuery<?> store) { Timestamp result = null; if (isTimestampOrVersionAvailable()) { TableField<R, ?> timestamp = getTable().getRecordTimestamp(); if (timestamp != null) { // Use Timestamp locally, to provide maximum precision result = new Timestamp(configuration().clock().millis()); addValue(store, timestamp, result); } } return result; }