Documentation for the "updater
" JSON key.
Updaters are a way altering a single field on the underlying database
Rather than configuring setClause
bean (more on this below) type queries, the following shortcut updater generators are also available:
fieldUpdaters
- For simple updaters on either a single field, which will return the number of rows that have been updated.
"tables": [
{
"fields": [
...
],
"updaters": [
...
]
}
]
Allowable keys for a Updater JSON Object
key name | key value type | usage | notes |
---|---|---|---|
name | String | mandatory | This is the name for the updater. If not present on the JSON object an H2ZeroParseException will be thrown. |
setClause | String | mandatory | Used for updaters only: You must provide a set clause which is valid SQL for inserting into the database. This will generate a FATAL validation message if not present on the JSON object. |
setFields | JSON Array (String) | mandatory | Select fields are mandatory for the updater JSON object. One field for each of the replacement tokens ? in the SQL set clause.This will generate a FATAL validation message if not present on the JSON object. |
whereClause | String | optional | Used if the SQL query is parameterised. |
whereFields | JSON Array (String) | optional | The name for each of the whereClause parameters.If there is a whereFields key on the JSON object without any whereClause then this will generate a FATAL validation message. |
unique | boolean (default false) | ignored | Whether the SQL query will return a single object or an List of objects.This is ignored, as updaters return the number of rows that have been updated as an integer. |
Default Updaters
By default Updaters
are designed to return the number of rows that have been updated
"updaters": [
{
"name": "updateFlIsIndexedByIdUser",
"setClause": "set fl_is_indexed = ?"",
"setFields": [
"fl_is_indexed"
],
"whereClause": "where id_user = ?",
"whereFields": [
"id_user"
]
}]
This will update the fl_is_indexed
to the passed in variable, where the id_user
is equal to the passed in variable.
With the following method signatures
public static int updateFlIsIndexedByIdUser(Connection connection, Boolean flIsIndexedSet, Long idUser) throws SQLException
public static int updateFlIsIndexedByIdUser(Boolean flIsIndexedSet, Long idUser) throws SQLException
public static int updateFlIsIndexedByIdUserSilent(Boolean flIsIndexedSet, Long idUser)
Please see the method signatures
page for information about usage patterns for the various method signatures that are generated.
If the "taglibs" option is enabled, this will also generate a tag library (and its associated entry in the TLD) file.