diff --git a/jOOQ-test/src/org/jooq/test/_/testcases/RecordTests.java b/jOOQ-test/src/org/jooq/test/_/testcases/RecordTests.java index 49e63c7b20..f8565dc077 100644 --- a/jOOQ-test/src/org/jooq/test/_/testcases/RecordTests.java +++ b/jOOQ-test/src/org/jooq/test/_/testcases/RecordTests.java @@ -41,6 +41,7 @@ import static junit.framework.Assert.assertTrue; import java.sql.Date; +import org.jooq.Field; import org.jooq.Record1; import org.jooq.Record2; import org.jooq.Record3; @@ -85,12 +86,14 @@ extends BaseTest field : changed.getFields()) { + assertEquals(changed.original(field), original.getValue(field)); + } } @Test diff --git a/jOOQ/src/main/java/org/jooq/Record.java b/jOOQ/src/main/java/org/jooq/Record.java index 35fce51f25..53e54a4613 100644 --- a/jOOQ/src/main/java/org/jooq/Record.java +++ b/jOOQ/src/main/java/org/jooq/Record.java @@ -365,9 +365,46 @@ public interface Record extends FieldProvider, Attachable { * Record values can be freely modified after having fetched a record from * the database. Every record also references the originally fetched values. * This method returns a new record containing those original values. + * + * @see #original(Field) + * @see #original(int) + * @see #original(String) */ Record original(); + /** + * Get an original value from this record as fetched from the database. + *

+ * Record values can be freely modified after having fetched a record from + * the database. Every record also references the originally fetched values. + * This method returns such an original value for a field. + * + * @see #original() + */ + T original(Field field); + + /** + * Get an original value from this record as fetched from the database. + *

+ * Record values can be freely modified after having fetched a record from + * the database. Every record also references the originally fetched values. + * This method returns such an original value for a field. + * + * @see #original() + */ + Object original(int fieldIndex); + + /** + * Get an original value from this record as fetched from the database. + *

+ * Record values can be freely modified after having fetched a record from + * the database. Every record also references the originally fetched values. + * This method returns such an original value for a field. + * + * @see #original() + */ + Object original(String fieldName); + /** * Check if this record has been changed from its original as fetched from * the database. @@ -376,24 +413,36 @@ public interface Record extends FieldProvider, Attachable { * record.equals(record.original()) is true. * * @see #original() + * @see #changed(Field) + * @see #changed(int) + * @see #changed(String) */ boolean changed(); /** * Check if a field's value has been changed from its original as fetched * from the database. + * + * @see #changed() + * @see #original(Field) */ boolean changed(Field field); /** * Check if a field's value has been changed from its original as fetched * from the database. + * + * @see #changed() + * @see #original(int) */ boolean changed(int fieldIndex); /** * Check if a field's value has been changed from its original as fetched * from the database. + * + * @see #changed() + * @see #original(String) */ boolean changed(String fieldName); @@ -606,11 +655,10 @@ public interface Record extends FieldProvider, Attachable { /** * Load data into this record from a source. The mapping algorithm is this: - *

If source is a {@link Map}

- * Loading of data is delegated to {@link #fromMap(Map)} - *

If any JPA {@link Column} annotations are found on the {@link Class} - * of the provided source, only those are used. Matching - * candidates are:

+ *

If source is a {@link Map}

Loading of data is + * delegated to {@link #fromMap(Map)}

If any JPA {@link Column} + * annotations are found on the {@link Class} of the provided + * source, only those are used. Matching candidates are:

*