diff --git a/jOOQ/src/main/java/org/jooq/UpdatableRecord.java b/jOOQ/src/main/java/org/jooq/UpdatableRecord.java index 892e4a2eca..509ef73aa3 100644 --- a/jOOQ/src/main/java/org/jooq/UpdatableRecord.java +++ b/jOOQ/src/main/java/org/jooq/UpdatableRecord.java @@ -255,6 +255,16 @@ public interface UpdatableRecord> extends TableReco * or inserted with default values (INSERT). *

* This is the same as calling record.store(record.fields()) + *

Effects on this record
+ *

+ * After a successful {@link #store()} operation, this record will have: + *

* * @return 1 if the record was stored to the database. 0 * if storing was not necessary. @@ -312,6 +322,15 @@ public interface UpdatableRecord> extends TableReco * {@link RecordDirtyTracking#TOUCHED} *

* This is the same as calling record.insert(record.fields()) + *

Effects on this record
+ *

+ * After a successful {@link #insert()} operation, this record will have: + *

* * @return 1 if the record was stored to the database. 0 * if storing was not necessary and @@ -365,6 +384,16 @@ public interface UpdatableRecord> extends TableReco * {@link Settings#getUpdateUnchangedRecords()}. *

* This is the same as calling record.update(record.fields()) + *

Effects on this record
+ *

+ * After a successful {@link #update()} operation, this record will have: + *

    + *
  • Its {@link #valuesRow()} unchanged
  • + *
  • Its {@link #original()} values set to the same values as + * {@link #valuesRow()}.
  • + *
  • Its {@link #touched()} flags set to false
  • + *
  • Its {@link #modified()} flags set to false
  • + *
* * @return 1 if the record was stored to the database. 0 * if storing was not necessary. @@ -427,6 +456,16 @@ public interface UpdatableRecord> extends TableReco * {@link RecordDirtyTracking#TOUCHED}. *

* This is the same as calling record.merge(record.fields()) + *

Effects on this record
+ *

+ * After a successful {@link #merge()} operation, this record will have: + *

    + *
  • Its {@link #valuesRow()} unchanged
  • + *
  • Its {@link #original()} values set to the same values as + * {@link #valuesRow()}.
  • + *
  • Its {@link #touched()} flags set to false
  • + *
  • Its {@link #modified()} flags set to false
  • + *
* * @return 1 if the record was merged to the database. 0 * if merging was not necessary. @@ -498,12 +537,25 @@ public interface UpdatableRecord> extends TableReco *

* See {@link SelectQuery#setForUpdate(boolean)} for more details * + *

Effects on this record
+ *

+ * After a successful {@link #delete()} operation, this record will have: + *

    + *
  • Its {@link #valuesRow()} unchanged
  • + *
  • Its {@link #original()} values reset to null
  • + *
  • Its {@link #touched()} flags set to true
  • + *
  • Its {@link #modified()} flags set to true
  • + *
*
Statement examples
*

- * The executed statement is


+     * The executed statement is
+     *
+     * 
+     * 
      * DELETE FROM [table]
      * WHERE [key fields = key values]
-     * AND [version/timestamp fields = version/timestamp values]
+ * AND [version/timestamp fields = version/timestamp values]
+ *
*

* This is in fact the same as calling * delete(getTable().getPrimaryKey().getFieldsArray()) @@ -608,6 +660,15 @@ public interface UpdatableRecord> extends TableReco * Duplicate this record (in memory) and reset all fields from the primary * key or main unique key, such that a subsequent call to {@link #store()} * will result in an INSERT statement. + *

Effects on this record
+ *

+ * After a {@link #copy()} operation, the resulting record will have: + *

    + *
  • Its {@link #valuesRow()} just like the source record
  • + *
  • Its {@link #original()} values set null.
  • + *
  • Its {@link #touched()} flags set to true
  • + *
  • Its {@link #modified()} flags set to false
  • + *
* * @return A new record, distinct from this record. */ diff --git a/jOOQ/src/main/java/org/jooq/impl/AbstractRecord.java b/jOOQ/src/main/java/org/jooq/impl/AbstractRecord.java index c7237693e6..3d5d7fe417 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AbstractRecord.java +++ b/jOOQ/src/main/java/org/jooq/impl/AbstractRecord.java @@ -520,9 +520,8 @@ implements // [#1995] If a value is meant to be "unchanged", the "original" should // match the supposedly "unchanged" value. - if (!c) { + if (!c) System.arraycopy(values, 0, originals, 0, values.length); - } } @Override diff --git a/jOOQ/src/main/java/org/jooq/impl/UpdatableRecordImpl.java b/jOOQ/src/main/java/org/jooq/impl/UpdatableRecordImpl.java index d490847413..413fbe617e 100644 --- a/jOOQ/src/main/java/org/jooq/impl/UpdatableRecordImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/UpdatableRecordImpl.java @@ -59,14 +59,13 @@ import static org.jooq.impl.RecordDelegate.RecordLifecycleType.REFRESH; import static org.jooq.impl.RecordDelegate.RecordLifecycleType.STORE; import static org.jooq.impl.RecordDelegate.RecordLifecycleType.UPDATE; import static org.jooq.impl.Tools.EMPTY_FIELD; -import static org.jooq.impl.Tools.EMPTY_TABLE_FIELD; import static org.jooq.impl.Tools.recordDirtyTrackingPredicate; import static org.jooq.impl.Tools.settings; import java.math.BigInteger; import java.sql.Timestamp; +import java.util.Arrays; import java.util.Collection; -import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -423,6 +422,7 @@ public class UpdatableRecordImpl> extends TableReco // be executed and the record should be recreated finally { touched(true); + asList(originals).replaceAll(e -> null); fetched = false; } }