public class UpdatableRecordImpl<R extends UpdatableRecord<R>> extends TableRecordImpl<R> implements UpdatableRecord<R>
This type is for JOOQ INTERNAL USE only. Do not reference directly
Constructor and Description |
---|
UpdatableRecordImpl(Table<R> table) |
Modifier and Type | Method and Description |
---|---|
void |
attach(Configuration c)
Attach this object to a new
Configuration . |
boolean |
changed()
Check if this record has been changed from its original as fetched from
the database.
|
void |
changed(boolean c)
Set all of this record's internal changed flags to the supplied value.
|
boolean |
changed(Field<?> field)
Check if a field's value has been changed from its original as fetched
from the database.
|
void |
changed(Field<?> field,
boolean c)
Set this record's internal changed flag to the supplied value for a given
field.
|
boolean |
changed(int fieldIndex)
Check if a field's value has been changed from its original as fetched
from the database.
|
void |
changed(int fieldIndex,
boolean c)
Set this record's internal changed flag to the supplied value for a given
field.
|
boolean |
changed(java.lang.String fieldName)
Check if a field's value has been changed from its original as fetched
from the database.
|
void |
changed(java.lang.String fieldName,
boolean c)
Set this record's internal changed flag to the supplied value for a given
field.
|
int |
compareTo(Record that)
Compares this
Record with another Record
according to their natural ordering. |
Configuration |
configuration()
Get the underlying configuration
|
R |
copy()
Duplicate this record (in memory) and reset all fields from the primary
key or main unique key, such that a subsequent call to
UpdatableRecord.store()
will result in an INSERT statement. |
protected DSLContext |
create()
This method is used in generated code!
|
int |
delete()
Deletes this record from the database, based on the value of the primary
key or main unique key.
|
void |
detach()
Detach this object from its current
Configuration . |
boolean |
equals(java.lang.Object obj) |
<O extends TableRecord<O>> |
fetchChild(ForeignKey<O,R> key)
Fetch a child record of this record, given a foreign key.
|
<O extends TableRecord<O>> |
fetchChildren(ForeignKey<O,R> key)
Fetch child records of this record, given a foreign key.
|
<T> Field<T> |
field(Field<T> field)
Get a specific field from this Record.
|
Field<?> |
field(int index)
Get a specific field from this Record.
|
Field<?> |
field(java.lang.String name)
Get a specific field from this Record.
|
Field<?>[] |
fields()
Get all fields from this Record.
|
Field<?>[] |
fields(Field<?>... f)
Get all fields from this Record, providing some fields.
|
Field<?>[] |
fields(int... fieldIndexes)
Get all fields from this Record, providing some field indexes.
|
Field<?>[] |
fields(java.lang.String... fieldNames)
Get all fields from this Record, providing some field names.
|
void |
from(java.lang.Object source)
Load data into this record from a source.
|
void |
from(java.lang.Object source,
Field<?>... f)
Load data into this record from a source, providing some fields.
|
void |
from(java.lang.Object source,
int... fieldIndexes)
Load data into this record from a source, providing some field indexes.
|
void |
from(java.lang.Object source,
java.lang.String... fieldNames)
Load data into this record from a source, providing some field names.
|
protected void |
from(Record source)
This method was implemented with [#799].
|
void |
fromArray(java.lang.Object... array)
Load data from an array into this record.
|
void |
fromArray(java.lang.Object[] array,
Field<?>... f)
Load data from an array into this record, providing some fields.
|
void |
fromArray(java.lang.Object[] array,
int... fieldIndexes)
Load data from an array into this record, providing some fields indexes.
|
void |
fromArray(java.lang.Object[] array,
java.lang.String... fieldNames)
Load data from an array into this record, providing some fields names.
|
void |
fromMap(java.util.Map<java.lang.String,?> map)
Load data from a map into this record.
|
void |
fromMap(java.util.Map<java.lang.String,?> map,
Field<?>... f)
Load data from a map into this record, providing some fields.
|
void |
fromMap(java.util.Map<java.lang.String,?> map,
int... fieldIndexes)
Load data from a map into this record, providing some field indexes.
|
void |
fromMap(java.util.Map<java.lang.String,?> map,
java.lang.String... fieldNames)
Load data from a map into this record, providing some field names.
|
<T> T |
getValue(Field<?> field,
java.lang.Class<? extends T> type)
Get a converted value from this Record, providing a field.
|
<T> T |
getValue(Field<?> field,
java.lang.Class<? extends T> type,
T defaultValue)
Deprecated.
|
<T> T |
getValue(Field<T> field)
Get a value from this Record, providing a field.
|
<T,U> U |
getValue(Field<T> field,
Converter<? super T,U> converter)
Get a converted value from this Record, providing a field.
|
<T,U> U |
getValue(Field<T> field,
Converter<? super T,U> converter,
U defaultValue)
Deprecated.
|
<T> T |
getValue(Field<T> field,
T defaultValue)
Deprecated.
|
java.lang.Object |
getValue(int index)
This method coincides with
Record.getValue(int) and
ArrayRecordImpl.getValue(int) |
<T> T |
getValue(int index,
java.lang.Class<? extends T> type)
Get a converted value from this record, providing a field index.
|
<T> T |
getValue(int index,
java.lang.Class<? extends T> type,
T defaultValue)
Deprecated.
|
<U> U |
getValue(int index,
Converter<?,U> converter)
Get a converted value from this record, providing a field index.
|
<U> U |
getValue(int index,
Converter<?,U> converter,
U defaultValue)
Deprecated.
|
java.lang.Object |
getValue(int index,
java.lang.Object defaultValue)
Deprecated.
|
java.lang.Object |
getValue(java.lang.String fieldName)
Get a value from this Record, providing a field name.
|
<T> T |
getValue(java.lang.String fieldName,
java.lang.Class<? extends T> type)
Get a converted value from this Record, providing a field name.
|
<T> T |
getValue(java.lang.String fieldName,
java.lang.Class<? extends T> type,
T defaultValue)
Deprecated.
|
<U> U |
getValue(java.lang.String fieldName,
Converter<?,U> converter)
Get a converted value from this Record, providing a field name.
|
<U> U |
getValue(java.lang.String fieldName,
Converter<?,U> converter,
U defaultValue)
Deprecated.
|
java.lang.Object |
getValue(java.lang.String fieldName,
java.lang.Object defaultValue)
Deprecated.
|
int |
hashCode() |
<E> E |
into(java.lang.Class<? extends E> type)
Map resulting records onto a custom type.
|
<E> E |
into(E object)
Map resulting records onto a custom type.
|
Record |
into(Field<?>... f)
Copy this record into a new record holding only a subset of the previous
fields.
|
<T1> Record1<T1> |
into(Field<T1> field1)
Copy this record into a new record holding only a subset of the previous
fields.
|
<T1,T2> Record2<T1,T2> |
into(Field<T1> field1,
Field<T2> field2)
Copy this record into a new record holding only a subset of the previous
fields.
|
<T1,T2,T3> Record3<T1,T2,T3> |
into(Field<T1> field1,
Field<T2> field2,
Field<T3> field3)
Copy this record into a new record holding only a subset of the previous
fields.
|
<T1,T2,T3,T4> |
into(Field<T1> field1,
Field<T2> field2,
Field<T3> field3,
Field<T4> field4)
Copy this record into a new record holding only a subset of the previous
fields.
|
<T1,T2,T3,T4,T5> |
into(Field<T1> field1,
Field<T2> field2,
Field<T3> field3,
Field<T4> field4,
Field<T5> field5)
Copy this record into a new record holding only a subset of the previous
fields.
|
<T1,T2,T3,T4,T5,T6> |
into(Field<T1> field1,
Field<T2> field2,
Field<T3> field3,
Field<T4> field4,
Field<T5> field5,
Field<T6> field6)
Copy this record into a new record holding only a subset of the previous
fields.
|
<T1,T2,T3,T4,T5,T6,T7> |
into(Field<T1> field1,
Field<T2> field2,
Field<T3> field3,
Field<T4> field4,
Field<T5> field5,
Field<T6> field6,
Field<T7> field7)
Copy this record into a new record holding only a subset of the previous
fields.
|
<T1,T2,T3,T4,T5,T6,T7,T8> |
into(Field<T1> field1,
Field<T2> field2,
Field<T3> field3,
Field<T4> field4,
Field<T5> field5,
Field<T6> field6,
Field<T7> field7,
Field<T8> field8)
Copy this record into a new record holding only a subset of the previous
fields.
|
<T1,T2,T3,T4,T5,T6,T7,T8,T9> |
into(Field<T1> field1,
Field<T2> field2,
Field<T3> field3,
Field<T4> field4,
Field<T5> field5,
Field<T6> field6,
Field<T7> field7,
Field<T8> field8,
Field<T9> field9)
Copy this record into a new record holding only a subset of the previous
fields.
|
<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> |
into(Field<T1> field1,
Field<T2> field2,
Field<T3> field3,
Field<T4> field4,
Field<T5> field5,
Field<T6> field6,
Field<T7> field7,
Field<T8> field8,
Field<T9> field9,
Field<T10> field10)
Copy this record into a new record holding only a subset of the previous
fields.
|
<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11> |
into(Field<T1> field1,
Field<T2> field2,
Field<T3> field3,
Field<T4> field4,
Field<T5> field5,
Field<T6> field6,
Field<T7> field7,
Field<T8> field8,
Field<T9> field9,
Field<T10> field10,
Field<T11> field11)
Copy this record into a new record holding only a subset of the previous
fields.
|
<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12> |
into(Field<T1> field1,
Field<T2> field2,
Field<T3> field3,
Field<T4> field4,
Field<T5> field5,
Field<T6> field6,
Field<T7> field7,
Field<T8> field8,
Field<T9> field9,
Field<T10> field10,
Field<T11> field11,
Field<T12> field12)
Copy this record into a new record holding only a subset of the previous
fields.
|
<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13> |
into(Field<T1> field1,
Field<T2> field2,
Field<T3> field3,
Field<T4> field4,
Field<T5> field5,
Field<T6> field6,
Field<T7> field7,
Field<T8> field8,
Field<T9> field9,
Field<T10> field10,
Field<T11> field11,
Field<T12> field12,
Field<T13> field13)
Copy this record into a new record holding only a subset of the previous
fields.
|
<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14> |
into(Field<T1> field1,
Field<T2> field2,
Field<T3> field3,
Field<T4> field4,
Field<T5> field5,
Field<T6> field6,
Field<T7> field7,
Field<T8> field8,
Field<T9> field9,
Field<T10> field10,
Field<T11> field11,
Field<T12> field12,
Field<T13> field13,
Field<T14> field14)
Copy this record into a new record holding only a subset of the previous
fields.
|
<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15> |
into(Field<T1> field1,
Field<T2> field2,
Field<T3> field3,
Field<T4> field4,
Field<T5> field5,
Field<T6> field6,
Field<T7> field7,
Field<T8> field8,
Field<T9> field9,
Field<T10> field10,
Field<T11> field11,
Field<T12> field12,
Field<T13> field13,
Field<T14> field14,
Field<T15> field15)
Copy this record into a new record holding only a subset of the previous
fields.
|
<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16> |
into(Field<T1> field1,
Field<T2> field2,
Field<T3> field3,
Field<T4> field4,
Field<T5> field5,
Field<T6> field6,
Field<T7> field7,
Field<T8> field8,
Field<T9> field9,
Field<T10> field10,
Field<T11> field11,
Field<T12> field12,
Field<T13> field13,
Field<T14> field14,
Field<T15> field15,
Field<T16> field16)
Copy this record into a new record holding only a subset of the previous
fields.
|
<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17> |
into(Field<T1> field1,
Field<T2> field2,
Field<T3> field3,
Field<T4> field4,
Field<T5> field5,
Field<T6> field6,
Field<T7> field7,
Field<T8> field8,
Field<T9> field9,
Field<T10> field10,
Field<T11> field11,
Field<T12> field12,
Field<T13> field13,
Field<T14> field14,
Field<T15> field15,
Field<T16> field16,
Field<T17> field17)
Copy this record into a new record holding only a subset of the previous
fields.
|
<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18> |
into(Field<T1> field1,
Field<T2> field2,
Field<T3> field3,
Field<T4> field4,
Field<T5> field5,
Field<T6> field6,
Field<T7> field7,
Field<T8> field8,
Field<T9> field9,
Field<T10> field10,
Field<T11> field11,
Field<T12> field12,
Field<T13> field13,
Field<T14> field14,
Field<T15> field15,
Field<T16> field16,
Field<T17> field17,
Field<T18> field18)
Copy this record into a new record holding only a subset of the previous
fields.
|
<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19> |
into(Field<T1> field1,
Field<T2> field2,
Field<T3> field3,
Field<T4> field4,
Field<T5> field5,
Field<T6> field6,
Field<T7> field7,
Field<T8> field8,
Field<T9> field9,
Field<T10> field10,
Field<T11> field11,
Field<T12> field12,
Field<T13> field13,
Field<T14> field14,
Field<T15> field15,
Field<T16> field16,
Field<T17> field17,
Field<T18> field18,
Field<T19> field19)
Copy this record into a new record holding only a subset of the previous
fields.
|
<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20> |
into(Field<T1> field1,
Field<T2> field2,
Field<T3> field3,
Field<T4> field4,
Field<T5> field5,
Field<T6> field6,
Field<T7> field7,
Field<T8> field8,
Field<T9> field9,
Field<T10> field10,
Field<T11> field11,
Field<T12> field12,
Field<T13> field13,
Field<T14> field14,
Field<T15> field15,
Field<T16> field16,
Field<T17> field17,
Field<T18> field18,
Field<T19> field19,
Field<T20> field20)
Copy this record into a new record holding only a subset of the previous
fields.
|
<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21> |
into(Field<T1> field1,
Field<T2> field2,
Field<T3> field3,
Field<T4> field4,
Field<T5> field5,
Field<T6> field6,
Field<T7> field7,
Field<T8> field8,
Field<T9> field9,
Field<T10> field10,
Field<T11> field11,
Field<T12> field12,
Field<T13> field13,
Field<T14> field14,
Field<T15> field15,
Field<T16> field16,
Field<T17> field17,
Field<T18> field18,
Field<T19> field19,
Field<T20> field20,
Field<T21> field21)
Copy this record into a new record holding only a subset of the previous
fields.
|
<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22> |
into(Field<T1> field1,
Field<T2> field2,
Field<T3> field3,
Field<T4> field4,
Field<T5> field5,
Field<T6> field6,
Field<T7> field7,
Field<T8> field8,
Field<T9> field9,
Field<T10> field10,
Field<T11> field11,
Field<T12> field12,
Field<T13> field13,
Field<T14> field14,
Field<T15> field15,
Field<T16> field16,
Field<T17> field17,
Field<T18> field18,
Field<T19> field19,
Field<T20> field20,
Field<T21> field21,
Field<T22> field22)
Copy this record into a new record holding only a subset of the previous
fields.
|
<R extends Record> |
into(Table<R> table)
Map resulting records onto a custom record type.
|
java.lang.Object[] |
intoArray()
Convert this record into an array.
|
java.util.List<java.lang.Object> |
intoList()
Convert this record into a list.
|
java.util.Map<java.lang.String,java.lang.Object> |
intoMap()
Return this record as a name/value map.
|
java.sql.ResultSet |
intoResultSet()
Generate an in-memory JDBC
ResultSet containing the data of this
Record . |
Record |
key()
A Record copy holding values for the
Table.getPrimaryKey() . |
<E> E |
map(RecordMapper<Record,E> mapper)
Map this record into a custom mapper callback.
|
<T> T |
original(Field<T> field)
Get an original value from this record as fetched from the database.
|
java.lang.Object |
original(int fieldIndex)
Get an original value from this record as fetched from the database.
|
java.lang.Object |
original(java.lang.String fieldName)
Get an original value from this record as fetched from the database.
|
void |
refresh()
Refresh this record from the database.
|
void |
refresh(Field<?>... refreshFields)
Refresh parts of this record from the database.
|
void |
reset()
|
void |
reset(Field<?> field)
Reset a given value to its
Record.original(Field) value and its
Record.changed(Field) flag to false . |
void |
reset(int fieldIndex)
|
void |
reset(java.lang.String fieldName)
Reset a given value to its
Record.original(String) value and its
Record.changed(String) flag to false . |
<T> void |
setValue(Field<T> field,
T value)
Set a value into this record.
|
<T,U> void |
setValue(Field<T> field,
U value,
Converter<T,? super U> converter)
Set a value into this record.
|
protected void |
setValue(int index,
java.lang.Object value)
Subclasses may type-unsafely set a value to a record index.
|
int |
size()
This method coincides with
Record.size() and
ArrayRecord.size() |
int |
store()
Store this record back to the database.
|
int |
store(Field<?>... storeFields)
Store parts of this record to the database.
|
java.lang.String |
toString() |
int |
update()
Store this record back to the database using an
UPDATE
statement. |
int |
update(Field<?>... storeFields)
Store parts of this record to the database using an
UPDATE
statement. |
fetchParent, fieldsRow, getTable, insert, insert, original, valuesRow
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
insert, insert
fetchParent, getTable, original
changed, changed, changed, changed, changed, changed, changed, changed, compareTo, equals, field, field, field, fields, fields, fields, fields, fieldsRow, from, from, from, from, fromArray, fromArray, fromArray, fromArray, fromMap, fromMap, fromMap, fromMap, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, hashCode, into, into, into, into, into, into, into, into, into, into, into, into, into, into, into, into, into, into, into, into, into, into, into, into, into, into, intoArray, intoList, intoMap, intoResultSet, map, original, original, original, reset, reset, reset, reset, setValue, setValue, size, valuesRow
attach, detach
public Record key()
UpdatableRecord
Table.getPrimaryKey()
.
The returned record consists exactly of those fields as returned by the
table's primary key: Key.getFields()
.
Generated subtypes may covariantly override this method to add more
record type information. For instance, they may return Record1
,
Record2
, ...
key
in interface UpdatableRecord<R extends UpdatableRecord<R>>
public final <O extends TableRecord<O>> O fetchChild(ForeignKey<O,R> key)
UpdatableRecord
This returns a child record referencing this record through a given
foreign key. If no child record was found, this returns null
fetchChild
in interface UpdatableRecord<R extends UpdatableRecord<R>>
ForeignKey.fetchChildren(java.util.Collection)
,
ForeignKey.fetchChildren(Record)
,
ForeignKey.fetchChildren(Record...)
public final <O extends TableRecord<O>> Result<O> fetchChildren(ForeignKey<O,R> key)
UpdatableRecord
This returns childs record referencing this record through a given foreign key.
fetchChildren
in interface UpdatableRecord<R extends UpdatableRecord<R>>
ForeignKey.fetchChildren(java.util.Collection)
,
ForeignKey.fetchChildren(Record)
,
ForeignKey.fetchChildren(Record...)
public final int store()
UpdatableRecord
Depending on the state of the primary key's value, an UpdatableRecord.insert()
or an UpdatableRecord.update()
statement is executed.
INSERT
statement is executedINSERT
statement is executed (unless
Settings.isUpdatablePrimaryKeys()
is set). jOOQ expects that
primary key values will never change due to the principle of
normalisation in RDBMS. So if client code changes primary key values,
this is interpreted by jOOQ as client code wanting to duplicate this
record.UPDATE
statement is executed.
In either statement type, only those fields are inserted/updated, which
had been explicitly set by client code, in order to allow for
DEFAULT
values to be applied by the underlying RDBMS. If no
fields were modified, neither an UPDATE
nor an
INSERT
will be executed.
Use UpdatableRecord.insert()
or UpdatableRecord.update()
to explicitly force either
statement type.
If there is an IDENTITY
column defined on the record's
underlying table (see Table.getIdentity()
), then the
auto-generated IDENTITY
value is refreshed automatically on
INSERT
's. Refreshing is done using
Statement.getGeneratedKeys()
, where this is supported by the JDBC
driver. See also InsertQuery.getReturnedRecord()
for more details
jOOQ can auto-generate "version" and "timestamp" values that can be used
for optimistic locking. If this is an UpdatableRecord
and if this
record returns fields for either Table.getRecordVersion()
or
Table.getRecordTimestamp()
, then these values are set onto the
INSERT
or UPDATE
statement being executed. On
execution success, the generated values are set to this record. Use the
code-generation configuration to specify naming patterns for
auto-generated "version" and "timestamp" columns.
Should you want to circumvent jOOQ-generated updates to these columns,
you can render an INSERT
or UPDATE
statement
manually using the various DSLContext.insertInto(Table)
,
DSLContext.update(Table)
methods.
If an UPDATE
statement is executed and
Settings.isExecuteWithOptimisticLocking()
is set to
true
, then this record will first be compared with the
latest state in the database. There are two modes of operation for
optimistic locking:
This is the preferred way of using optimistic locking in jOOQ. If this is
an UpdatableRecord
and if this record returns fields for either
Table.getRecordVersion()
or Table.getRecordTimestamp()
,
then these values are compared to the corresponding value in the database
in the WHERE
clause of the executed DELETE
statement.
In order to compare this record with the latest state, the database
record will be locked pessimistically using a
SELECT .. FOR UPDATE
statement. Not all databases support
the FOR UPDATE
clause natively. Namely, the following
databases will show slightly different behaviour:
SQLDialect.CUBRID
and SQLDialect.SQLSERVER
: jOOQ will
try to lock the database record using JDBC's
ResultSet.TYPE_SCROLL_SENSITIVE
and
ResultSet.CONCUR_UPDATABLE
.SQLDialect.SQLITE
: No pessimistic locking is possible. Client
code must assure that no race-conditions can occur between jOOQ's
checking of database record state and the actual UPDATE
See SelectQuery.setForUpdate(boolean)
for more details
Possible statements are
INSERT INTO [table] ([modified fields, including keys])
VALUES ([modified values, including keys])
UPDATE [table]
SET [modified fields = modified values, excluding keys]
WHERE [key fields = key values]
AND [version/timestamp fields = version/timestamp values]
If you want to enforce statement execution, regardless if the values in
this record were changed, you can explicitly set the changed flags for
all values with Record.changed(boolean)
or for single values with
Record.changed(Field, boolean)
, prior to storing.
This is the same as calling record.store(record.fields())
store
in interface UpdatableRecord<R extends UpdatableRecord<R>>
1
if the record was stored to the database. 0
if storing was not necessary.UpdatableRecord.insert()
,
UpdatableRecord.update()
public final int store(Field<?>... storeFields) throws DataAccessException, DataChangedException
UpdatableRecord
store
in interface UpdatableRecord<R extends UpdatableRecord<R>>
1
if the record was stored to the database. 0
if storing was not necessary.DataAccessException
- if something went wrong executing the queryDataChangedException
- If optimistic locking is enabled and the
record has already been changed/deleted in the databaseUpdatableRecord.store()
,
UpdatableRecord.insert(Field...)
,
UpdatableRecord.update(Field...)
public final int update()
UpdatableRecord
UPDATE
statement.
This is the same as UpdatableRecord.store()
, except that an UPDATE
statement (or no statement) will always be executed.
If you want to enforce statement execution, regardless if the values in
this record were changed, you can explicitly set the changed flags for
all values with Record.changed(boolean)
or for single values with
Record.changed(Field, boolean)
, prior to updating.
This is the same as calling record.update(record.fields())
update
in interface UpdatableRecord<R extends UpdatableRecord<R>>
1
if the record was stored to the database. 0
if storing was not necessary.UpdatableRecord.store()
public int update(Field<?>... storeFields) throws DataAccessException, DataChangedException
UpdatableRecord
UPDATE
statement.update
in interface UpdatableRecord<R extends UpdatableRecord<R>>
1
if the record was stored to the database. 0
if storing was not necessary.DataAccessException
- if something went wrong executing the queryDataChangedException
- If optimistic locking is enabled and the
record has already been changed/deleted in the databaseUpdatableRecord.update()
public final int delete()
UpdatableRecord
If a DELETE
statement is executed and
Settings.isExecuteWithOptimisticLocking()
is set to
true
, then this record will first be compared with the
latest state in the database. There are two modes of operation for
optimistic locking:
This is the preferred way of using optimistic locking in jOOQ. If this is
an UpdatableRecord
and if this record returns fields for either
Table.getRecordVersion()
or
Table.getRecordTimestamp()
, then these values are
compared to the corresponding value in the database in the
WHERE
clause of the executed DELETE
statement.
In order to compare this record with the latest state, the database
record will be locked pessimistically using a
SELECT .. FOR UPDATE
statement. Not all databases support
the FOR UPDATE
clause natively. Namely, the following
databases will show slightly different behaviour:
SQLDialect.CUBRID
and SQLDialect.SQLSERVER
: jOOQ will
try to lock the database record using JDBC's
ResultSet.TYPE_SCROLL_SENSITIVE
and
ResultSet.CONCUR_UPDATABLE
.SQLDialect.SQLITE
: No pessimistic locking is possible. Client
code must assure that no race-conditions can occur between jOOQ's
checking of database record state and the actual DELETE
See SelectQuery.setForUpdate(boolean)
for more details
The executed statement is
DELETE FROM [table]
WHERE [key fields = key values]
AND [version/timestamp fields = version/timestamp values]
This is in fact the same as calling
delete(getTable().getPrimaryKey().getFieldsArray())
delete
in interface UpdatableRecord<R extends UpdatableRecord<R>>
1
if the record was deleted from the database.
0
if deletion was not necessary.public final void refresh()
UpdatableRecord
A successful refresh results in the following:
Record.valuesRow()
will have been restored to the respective values
from the databaseTableRecord.original()
will match this recordRecord.changed()
will be false
Refreshing can trigger any of the following actions:
SELECT
statement, if this is an
UpdatableRecord
.
This is the same as calling record.refresh(record.fields())
refresh
in interface UpdatableRecord<R extends UpdatableRecord<R>>
public final void refresh(Field<?>... refreshFields)
UpdatableRecord
A successful refresh results in the following:
Record.valuesRow()
will have been restored to the respective values
from the databaseTableRecord.original()
will match this recordRecord.changed()
will be false
Refreshing can trigger any of the following actions:
SELECT
statement, if this is an
UpdatableRecord
.
This is the same as calling record.refresh(record.fields())
refresh
in interface UpdatableRecord<R extends UpdatableRecord<R>>
public final R copy()
UpdatableRecord
UpdatableRecord.store()
will result in an INSERT
statement.copy
in interface UpdatableRecord<R extends UpdatableRecord<R>>
this
record.public final <T> Field<T> field(Field<T> field)
Record
field
in interface Record
Row.field(Field)
public final Field<?> field(java.lang.String name)
Record
field
in interface Record
Row.field(String)
public final Field<?> field(int index)
Record
field
in interface Record
Row.field(int)
public final Field<?>[] fields()
Record
fields
in interface Record
Row.fields()
public final Field<?>[] fields(Field<?>... f)
Record
fields
in interface Record
Row.fields(Field...)
public final Field<?>[] fields(java.lang.String... fieldNames)
Record
fields
in interface Record
Row.fields(String...)
public final Field<?>[] fields(int... fieldIndexes)
Record
fields
in interface Record
Row.fields(int...)
public final int size()
Record.size()
and
ArrayRecord.size()
public final <T> T getValue(Field<T> field)
Record
If this record contains a field with the same Field.getName()
as
the argument field, that value is retrieved.
@Deprecated public final <T> T getValue(Field<T> field, T defaultValue)
Record
public final <T> T getValue(Field<?> field, java.lang.Class<? extends T> type)
Record
If this record contains a field with the same Field.getName()
as
the argument field, that value is retrieved.
getValue
in interface Record
T
- The conversion type parameterfield
- The fieldtype
- The conversion typeConvert.convert(Object, Class)
@Deprecated public final <T> T getValue(Field<?> field, java.lang.Class<? extends T> type, T defaultValue)
Record
getValue
in interface Record
T
- The conversion type parameterfield
- The fieldtype
- The conversion typedefaultValue
- The default value instead of null
null
Convert.convert(Object, Class)
public final <T,U> U getValue(Field<T> field, Converter<? super T,U> converter)
Record
If this record contains a field with the same Field.getName()
as
the argument field, that value is retrieved.
getValue
in interface Record
T
- The database type parameterU
- The conversion type parameterfield
- The fieldconverter
- The data type converterConvert.convert(Object, Converter)
@Deprecated public final <T,U> U getValue(Field<T> field, Converter<? super T,U> converter, U defaultValue)
Record
getValue
in interface Record
T
- The database type parameterU
- The conversion type parameterfield
- The fieldconverter
- The data type converterdefaultValue
- The default value instead of null
null
Convert.convert(Object, Converter)
public final java.lang.Object getValue(int index)
Record.getValue(int)
and
ArrayRecordImpl.getValue(int)
@Deprecated public final java.lang.Object getValue(int index, java.lang.Object defaultValue)
Record
public final <T> T getValue(int index, java.lang.Class<? extends T> type)
Record
getValue
in interface Record
T
- The conversion type parameterindex
- The field's indextype
- The conversion typeConvert.convert(Object, Class)
@Deprecated public final <T> T getValue(int index, java.lang.Class<? extends T> type, T defaultValue)
Record
getValue
in interface Record
T
- The conversion type parameterindex
- The field's indextype
- The conversion typedefaultValue
- The default value instead of null
null
Convert.convert(Object, Class)
public final <U> U getValue(int index, Converter<?,U> converter)
Record
getValue
in interface Record
U
- The conversion type parameterindex
- The field's indexconverter
- The data type converterConvert.convert(Object, Converter)
@Deprecated public final <U> U getValue(int index, Converter<?,U> converter, U defaultValue)
Record
getValue
in interface Record
U
- The conversion type parameterindex
- The field's indexconverter
- The data type converterdefaultValue
- The default value instead of null
null
Convert.convert(Object, Converter)
public final java.lang.Object getValue(java.lang.String fieldName)
Record
@Deprecated public final java.lang.Object getValue(java.lang.String fieldName, java.lang.Object defaultValue)
Record
public final <T> T getValue(java.lang.String fieldName, java.lang.Class<? extends T> type)
Record
getValue
in interface Record
T
- The conversion type parameterfieldName
- The field's nametype
- The conversion typeConvert.convert(Object, Class)
@Deprecated public final <T> T getValue(java.lang.String fieldName, java.lang.Class<? extends T> type, T defaultValue)
Record
getValue
in interface Record
T
- The conversion type parameterfieldName
- The field's nametype
- The conversion typedefaultValue
- The default value instead of null
null
Convert.convert(Object, Class)
public final <U> U getValue(java.lang.String fieldName, Converter<?,U> converter)
Record
getValue
in interface Record
U
- The conversion type parameterfieldName
- The field's nameconverter
- The data type converterConvert.convert(Object, Converter)
@Deprecated public final <U> U getValue(java.lang.String fieldName, Converter<?,U> converter, U defaultValue)
Record
getValue
in interface Record
U
- The conversion type parameterfieldName
- The field's nameconverter
- The data type converterdefaultValue
- The default value instead of null
null
Convert.convert(Object, Converter)
protected final void setValue(int index, java.lang.Object value)
public final <T> void setValue(Field<T> field, T value)
Record
This will always set the Record.changed(Field)
flag for the given
field
, no matter if setting the value actually changes the
value.
Changing Table.getPrimaryKey()
values will set all
Record.changed()
flags to true, in order to produce complete
INSERT
statements on subsequent
UpdatableRecord.store()
operations.
public final <T,U> void setValue(Field<T> field, U value, Converter<T,? super U> converter)
Record
This will always set the Record.changed(Field)
flag for the given
field
, no matter if setting the value actually changes the
value.
Changing Table.getPrimaryKey()
values will set all
Record.changed()
flags to true, in order to produce complete
INSERT
statements on subsequent
UpdatableRecord.store()
operations.
public final <T> T original(Field<T> field)
Record
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.
original
in interface Record
Record.original()
public final java.lang.Object original(int fieldIndex)
Record
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.
original
in interface Record
Record.original()
public final java.lang.Object original(java.lang.String fieldName)
Record
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.
original
in interface Record
Record.original()
public final boolean changed()
Record
If this returns false
, then it can be said that
record.equals(record.original())
is true.
changed
in interface Record
Record.original()
,
Record.changed(Field)
,
Record.changed(int)
,
Record.changed(String)
public final boolean changed(Field<?> field)
Record
changed
in interface Record
Record.changed()
,
Record.original(Field)
public final boolean changed(int fieldIndex)
Record
changed
in interface Record
Record.changed()
,
Record.original(int)
public final boolean changed(java.lang.String fieldName)
Record
changed
in interface Record
Record.changed()
,
Record.original(String)
public final void changed(boolean c)
Record
If the changed
argument is false
, the
Record.original()
values will be reset to the corresponding "current"
values as well
changed
in interface Record
Record.changed()
,
Record.changed(Field, boolean)
,
Record.changed(int, boolean)
,
Record.changed(String, boolean)
public final void changed(Field<?> field, boolean c)
Record
If the changed
argument is false
, the
Record.original(Field)
value will be reset to the corresponding
"current" value as well
changed
in interface Record
Record.changed()
,
Record.changed(Field)
public final void changed(int fieldIndex, boolean c)
Record
If the changed
argument is false
, the
Record.original(int)
value will be reset to the corresponding "current"
value as well
changed
in interface Record
Record.changed()
,
Record.changed(int)
public final void changed(java.lang.String fieldName, boolean c)
Record
If the changed
argument is false
, the
Record.original(String)
value will be reset to the corresponding
"current" value as well
changed
in interface Record
Record.changed()
,
Record.changed(String)
public final void reset()
Record
public final void reset(Field<?> field)
Record
Record.original(Field)
value and its
Record.changed(Field)
flag to false
.public final void reset(int fieldIndex)
Record
public final void reset(java.lang.String fieldName)
Record
Record.original(String)
value and its
Record.changed(String)
flag to false
.public final java.lang.Object[] intoArray()
Record
The resulting array has the same number of elements as this record has fields. The resulting array contains data as such:
// For arbitrary values of i
record.getValue(i) == record.intoArray()[i]
This is the same as calling into(Object[].class)
intoArray
in interface Record
Record.fromArray(Object...)
public final java.util.List<java.lang.Object> intoList()
Record
The resulting list has the same number of elements as this record has fields. The resulting array contains data as such:
// For arbitrary values of i
record.getValue(i) == record.intoList().get(i)
This is the same as calling Arrays.asList(intoArray())
public final java.util.Map<java.lang.String,java.lang.Object> intoMap()
Record
This is the inverse operation to Record.fromMap(Map)
intoMap
in interface Record
Record.fromMap(Map)
public final Record into(Field<?>... f)
Record
public final <T1> Record1<T1> into(Field<T1> field1)
Record
public final <T1,T2> Record2<T1,T2> into(Field<T1> field1, Field<T2> field2)
Record
public final <T1,T2,T3> Record3<T1,T2,T3> into(Field<T1> field1, Field<T2> field2, Field<T3> field3)
Record
public final <T1,T2,T3,T4> Record4<T1,T2,T3,T4> into(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4)
Record
public final <T1,T2,T3,T4,T5> Record5<T1,T2,T3,T4,T5> into(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5)
Record
public final <T1,T2,T3,T4,T5,T6> Record6<T1,T2,T3,T4,T5,T6> into(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6)
Record
public final <T1,T2,T3,T4,T5,T6,T7> Record7<T1,T2,T3,T4,T5,T6,T7> into(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7)
Record
public final <T1,T2,T3,T4,T5,T6,T7,T8> Record8<T1,T2,T3,T4,T5,T6,T7,T8> into(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8)
Record
public final <T1,T2,T3,T4,T5,T6,T7,T8,T9> Record9<T1,T2,T3,T4,T5,T6,T7,T8,T9> into(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9)
Record
public final <T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> Record10<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> into(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10)
Record
public final <T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11> Record11<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11> into(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11)
Record
public final <T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12> Record12<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12> into(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12)
Record
public final <T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13> Record13<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13> into(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13)
Record
public final <T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14> Record14<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14> into(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14)
Record
public final <T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15> Record15<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15> into(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15)
Record
public final <T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16> Record16<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16> into(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16)
Record
public final <T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17> Record17<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17> into(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16, Field<T17> field17)
Record
public final <T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18> Record18<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18> into(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16, Field<T17> field17, Field<T18> field18)
Record
public final <T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19> Record19<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19> into(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16, Field<T17> field17, Field<T18> field18, Field<T19> field19)
Record
public final <T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20> Record20<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20> into(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16, Field<T17> field17, Field<T18> field18, Field<T19> field19, Field<T20> field20)
Record
public final <T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21> Record21<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21> into(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16, Field<T17> field17, Field<T18> field18, Field<T19> field19, Field<T20> field20, Field<T21> field21)
Record
public final <T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22> Record22<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22> into(Field<T1> field1, Field<T2> field2, Field<T3> field3, Field<T4> field4, Field<T5> field5, Field<T6> field6, Field<T7> field7, Field<T8> field8, Field<T9> field9, Field<T10> field10, Field<T11> field11, Field<T12> field12, Field<T13> field13, Field<T14> field14, Field<T15> field15, Field<T16> field16, Field<T17> field17, Field<T18> field18, Field<T19> field19, Field<T20> field20, Field<T21> field21, Field<T22> field22)
Record
public final <E> E into(java.lang.Class<? extends E> type)
Record
This will map this record onto your custom type using a
RecordMapper
as provided by
Configuration.recordMapperProvider()
. If no custom provider is
specified, the DefaultRecordMapperProvider
is used.
into
in interface Record
E
- The generic entity type.type
- The entity type.Record.from(Object)
,
DefaultRecordMapper
public final <E> E into(E object)
Record
This is the same as Record.into(Class)
, except that no new object is
instantiated as a result. Instead, you can provide your own custom POJO
instance.
into
in interface Record
E
- The generic entity type.object
- The receiving bean.Record.from(Object)
public final <R extends Record> R into(Table<R> table)
Record
The mapping algorithm is this:
Record
values by equal field names:
table
argument with
Field.getName()
"MY_field"
(case-sensitive!), a
corresponding field with the same name in this record will be searched.Field.getName()
, then the first one returning true on
Field.equals(Object)
will be returned. (e.g. qualified field
names match)
Table.getRecordType()
must return a class of type
TableRecord
, which must provide a default constructor. Non-public
default constructors are made accessible using
AccessibleObject.setAccessible(boolean)
public final java.sql.ResultSet intoResultSet()
Record
ResultSet
containing the data of this
Record
.
Use this as an adapter for JDBC-compliant code that expects a
ResultSet
to operate on, rather than a jOOQ Result
. The
returned ResultSet
allows for the following behaviour
according to the JDBC specification:
ResultSet.CLOSE_CURSORS_AT_COMMIT
: The cursors (i.e.
Statement
object) are no longer availableResultSet.CONCUR_READ_ONLY
: You cannot update the database
through this ResultSet
, as the underlying Result
object does not hold any open database refences anymoreResultSet.FETCH_FORWARD
: The fetch direction is forward only,
and cannot be changedResultSet.TYPE_SCROLL_INSENSITIVE
: You can use any of the
ResultSet
's scrolling methods, e.g. ResultSet.next()
or ResultSet.previous()
, etc.
You may use DSLContext.fetch(ResultSet)
to unwind this wrapper
again.
This is the same as creating a new Result
with this
Record
only, and then calling Result.intoResultSet()
on that Result
intoResultSet
in interface Record
ResultSet
public final <E> E map(RecordMapper<Record,E> mapper)
Record
public final void from(java.lang.Object source)
Record
The mapping algorithm is this:
source
is an array
Loading of data is delegated to Record.fromArray(Object...)
source
is a Map
Loading of data is delegated to Record.fromMap(Map)
Column
annotations are found on the Class
of the provided source
, only those are used. Matching
candidates are:
Column
getXXX
or isXXX
, if there exists a matching public single-argument
setXXX()
instance method that is annotated with
Column
Column
Column.name()
must match Field.getName()
. All other
annotation attributes are ignored
Column
annotations, or jOOQ can't
find the javax.persistence
API on the classpath, jOOQ will
map members by naming convention:
If Field.getName()
is MY_field
(case-sensitive!),
then this field's value will be fetched from the first of these:
MY_field()
myField()
getMY_field()
getMyField()
MY_field
myField
The resulting record will have its internal "changed" flags set to true
for all values. This means that UpdatableRecord.store()
will
perform an INSERT
statement. If you wish to store the record
using an UPDATE
statement, use
DSLContext.executeUpdate(UpdatableRecord)
instead.
This is the same as calling
record.from(source, record.fields())
from
in interface Record
source
- The source object to copy data fromRecord.into(Class)
,
Record.from(Object, Field...)
public final void from(java.lang.Object source, Field<?>... f)
Record
This is the same as Record.from(Object)
, except that only fields
contained in the fields
argument will be mapped.
from
in interface Record
source
- The source object to copy data fromf
- The record's fields to use for mappingRecord.into(Class)
,
Record.from(Object)
public final void from(java.lang.Object source, java.lang.String... fieldNames)
Record
This is the same as Record.from(Object)
, except that only fields
contained in the fieldNames
argument will be mapped.
from
in interface Record
source
- The source object to copy data fromfieldNames
- The record's fields names to use for mappingRecord.into(Class)
,
Record.from(Object)
public final void from(java.lang.Object source, int... fieldIndexes)
Record
This is the same as Record.from(Object)
, except that only fields
contained in the fieldIndexes
argument will be mapped.
from
in interface Record
source
- The source object to copy data fromfieldIndexes
- The record's fields indexes to use for mappingRecord.into(Class)
,
Record.from(Object)
public final void fromMap(java.util.Map<java.lang.String,?> map)
Record
The argument map is expected to hold field-name / value pairs where
field-names correspond to actual field names as provided by
Record.field(String)
. Missing fields will be left untouched. Excess
fields will be ignored.
This is the inverse operation to Record.intoMap()
. This is the same as
calling record.fromMap(map, record.fields())
fromMap
in interface Record
Record.intoMap()
,
Record.fromMap(Map, Field...)
public final void fromMap(java.util.Map<java.lang.String,?> map, Field<?>... f)
Record
The argument map is expected to hold field-name / value pairs where
field-names correspond to actual field names as provided by
Record.field(String)
. Missing fields will be left untouched. Excess
fields will be ignored.
This is the same as Record.fromMap(Map)
, except that only fields
contained in the fields
argument will be mapped.
fromMap
in interface Record
Record.intoMap()
,
Record.fromMap(Map)
public final void fromMap(java.util.Map<java.lang.String,?> map, java.lang.String... fieldNames)
Record
The argument map is expected to hold field-name / value pairs where
field-names correspond to actual field names as provided by
Record.field(String)
. Missing fields will be left untouched. Excess
fields will be ignored.
This is the same as Record.fromMap(Map)
, except that only fields
contained in the fieldNames
argument will be mapped.
fromMap
in interface Record
Record.intoMap()
,
Record.fromMap(Map)
public final void fromMap(java.util.Map<java.lang.String,?> map, int... fieldIndexes)
Record
The argument map is expected to hold field-name / value pairs where
field-names correspond to actual field names as provided by
Record.field(String)
. Missing fields will be left untouched. Excess
fields will be ignored.
This is the same as Record.fromMap(Map)
, except that only fields
contained in the fieldIndexes
argument will be mapped.
fromMap
in interface Record
Record.intoMap()
,
Record.fromMap(Map)
public final void fromArray(java.lang.Object... array)
Record
The argument array is expected to hold values for this record's field indexes. Missing values will be left untouched. Excess values will be ignored.
This is the inverse operation to Record.intoArray()
fromArray
in interface Record
Record.intoArray()
,
Record.fromArray(Object[], Field...)
public final void fromArray(java.lang.Object[] array, Field<?>... f)
Record
The argument array is expected to hold values for this record's field indexes. Missing values will be left untouched. Excess values will be ignored.
This is the same as Record.fromArray(Object...)
, except that only
fields contained in the fields
argument will be mapped.
fromArray
in interface Record
Record.intoArray()
,
Record.fromArray(Object...)
public final void fromArray(java.lang.Object[] array, java.lang.String... fieldNames)
Record
The argument array is expected to hold values for this record's field indexes. Missing values will be left untouched. Excess values will be ignored.
This is the same as Record.fromArray(Object...)
, except that only
fields contained in the fieldNames
argument will be mapped.
fromArray
in interface Record
Record.intoArray()
,
Record.fromArray(Object...)
public final void fromArray(java.lang.Object[] array, int... fieldIndexes)
Record
The argument array is expected to hold values for this record's field indexes. Missing values will be left untouched. Excess values will be ignored.
This is the same as Record.fromArray(Object...)
, except that only
fields contained in the fieldIndexes
argument will be
mapped.
fromArray
in interface Record
Record.intoArray()
,
Record.fromArray(Object...)
protected final void from(Record source)
public java.lang.String toString()
toString
in class java.lang.Object
public int compareTo(Record that)
Record
Record
with another Record
according to their natural ordering.
jOOQ Records implement Comparable
to allow for naturally ordering
Records in a "SQL way", i.e. according to the following rules:
Two Records are comparable if and only if they have the same
ROW
type, i.e. if their fieldsRow()
methods return fields of the same type and degree.
Assume the following notations:
X[i]
means X.getValue(i)
X = Y
means X.compareTo(Y) == 0
X < Y
means X.compareTo(Y) < 0
X[i] = Y[i]
means
(X[i] == null && Y[i] == null) || X[i].compareTo(Y[i]) < 0
X[i] < Y[i]
means
Y[i] == null || X[i].compareTo(Y[i]) < 0
. This
corresponds to the SQL NULLS LAST
clause.r1
and r2
,
x = r1.compareTo(r2)
yields:
x = -1
: if
(r1[0] < r2[0])
OR (r1[0] = r2[0] AND r1[1] < r2[1])
OR ...
OR (r1[0] = r2[0] AND ... AND r1[N-1] = r2[N-1] AND r1[N] < r2[N])
x = 0
: if
OR (r1[0] = r2[0] AND ... AND r1[N-1] = r2[N-1] AND r1[N] = r2[N])
x = 1
: if
(r1[0] > r2[0])
OR (r1[0] = r2[0] AND r1[1] > r2[1])
OR ...
OR (r1[0] = r2[0] AND ... AND r1[N-1] = r2[N-1] AND r1[N] > r2[N])
Note, that the above rules correspond to the SQL ordering behaviour as
illustrated in the following examples:
-- A SQL ORDER BY clause, ordering all records by columns in their order
SELECT a, b, c
FROM my_table
ORDER BY 1, 2, 3
-- A row value expression comparison predicate
SELECT *
FROM my_table
WHERE (a, b, c) < (1, 2, 3)
See Row1.lessThan(Row1)
, Row2.lessThan(Row2)
, ...,
Row22.lessThan(Row22)
for more details about row value expression
comparison predicates
Alternative sorting behaviour can be achieved through
Result.sortAsc(java.util.Comparator)
and similar methods.
public final void attach(Configuration c)
Attachable
Configuration
.attach
in interface Attachable
c
- A configuration or null
, if you wish to
detach this Attachable
from its previous
configuration.public final void detach()
Attachable
Configuration
.
This is the same as calling attach(null)
.
detach
in interface Attachable
public final Configuration configuration()
AttachableInternal
configuration
in interface AttachableInternal
protected final DSLContext create()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
Copyright © 2015. All Rights Reserved.