|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
R
- The record typepublic interface UpdatableRecord<R extends UpdatableRecord<R>>
A common interface for records that can be stored back to the database again.
Any Record
can be Updatable
, if
TableRecord
The "main unique key" is used by jOOQ to perform the various operations that
can be performed on an UpdatableRecord
:
delete()
: Deleting the recordrefresh()
: Refreshing the records attributes (or loading it for
the first time)store()
: Storing the record to the database. This executes
either an INSERT
or an UPDATE
statement
UpdatableRecords
are Attachable
, which means that they
hold an underlying Configuration
that they can be detached from. They
can also be instanciated without any underlying Configuration
, in
case of which they have to be attached first, in order to be refreshed,
stored, or deleted.
Method Summary | |
---|---|
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 store()
will result in an INSERT statement. |
int |
delete()
Deletes this record from the database, based on the value of the primary key or main unique key. |
UpdatableTable<R> |
getTable()
The table from which this record was read |
void |
refresh()
Refresh this record from the database, based on the value of the primary key or main unique key. |
int |
store()
Store this record back to the database. |
Methods inherited from interface org.jooq.TableRecord |
---|
deleteUsing, refreshUsing, storeUsing |
Methods inherited from interface org.jooq.FieldProvider |
---|
getField, getField, getField, getFields, getIndex |
Methods inherited from interface org.jooq.Attachable |
---|
attach |
Methods inherited from interface org.jooq.Adapter |
---|
internalAPI |
Method Detail |
---|
UpdatableTable<R> getTable()
getTable
in interface TableRecord<R extends UpdatableRecord<R>>
int store() throws DataAccessException
Depending on the state of the primary key's or main unique key's value,
an INSERT
or an UPDATE
statement is executed.
INSERT
statement is executedINSERT
statement is executed. 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, 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. Possible statements are
INSERT INTO [table] ([modified fields, including main key])
VALUES ([modified values, including main key])
UPDATE [table]
SET [modified fields = modified values, excluding main key]
WHERE [main key fields = main key values]
This is in fact the same as calling
store(getTable().getMainKey().getFieldsArray())
1
if the record was stored to the database. 0
if storing was not necessary.
DataAccessException
- if something went wrong executing the queryTableRecord.storeUsing(TableField...)
int delete() throws DataAccessException
The executed statement is
DELETE FROM [table]
WHERE [main key fields = main key values]
This is in fact the same as calling
delete(getTable().getMainKey().getFieldsArray())
1
if the record was deleted from the database.
0
if deletion was not necessary.
DataAccessException
- if something went wrong executing the queryTableRecord.deleteUsing(TableField...)
void refresh() throws DataAccessException
This is in fact the same as calling
refresh(getTable().getMainKey().getFieldsArray())
The executed statement is
SELECT * FROM [table]
WHERE [main key fields = main key values]
DataAccessException
- This exception is thrown if
TableRecord.refreshUsing(TableField...)
R copy()
store()
will result in an INSERT
statement.
this
record.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |