Interface Persistor
- All Known Implementing Classes:
JdbcPersistorImpl
A Persistor is a class that handles callbacks from the Transformers persistence module and acts as a Bridge between Transformer and any Database
When an implementation of Persistor
is loaded by Transformer,
transformer looks for a constructor that takes exactly two Arguments of type
PersistorConfiguration
and Logger
. If this constructor is not available,
the default constructor gets called
-
Method Summary
Modifier and TypeMethodDescriptionCall a stored procedure in the database.int
Delete one or more rows from a tableonQuery
(String table, String query, QueryParams params) Query the database for results.void
Called when transformer shuts down to close open connections and release acquired resourcesint
Implement this method to handle update or insert callbacks.
-
Method Details
-
onUpsert
Implement this method to handle update or insert callbacks. This method is expected to update an existing row or insert a new one if the update did not affect any rows
This method should attempt to update an existing row first by setting all the values given in data and using the entries of this map where the key matches
key
anded together in the where clause like:"key1=value1 and key2=value2"
. If the update did not affect any rows, then an insert should be executed with the data given- Parameters:
table
- The table to be modifiedkeys
- Map containing column/value pairs to be used in the where clause for updates. If no row matches the criteria, a combination ofkeys
anddata
is used as data for the rows, where entries indata
take precedence over entries inkeys
data
- Map containing column/value pairs to be set in the row identified bykeys
- Returns:
- -1 on error or >=0 affected rows on success
-
onQuery
Query the database for results.
Queries the database with
query
being a valid sql selection andargs
being a list of arguments that get bound to ? in the query string- Parameters:
table
- The table name to execute the query on.query
- a valid sql where clause or an empty string for all rows.params
-QueryParams
to be used for the query- Returns:
- null on error, an empty array if there were no results or an array holding all the rows returned by the query.
-
onDelete
Delete one or more rows from a table
Delete rows where the all the columns specified in selector match their specified values
- Parameters:
table
- The table name to delete from.selector
- Map of column names (keys) and values to be anded together in the where clause.- Returns:
- true if the operation affected more than 0 rows, false otherwise.
-
onCall
Call a stored procedure in the database.
Calls a stored procedure in the database with
procedureName
being a valid procedure name within the database andargs
being a list of arguments to pass to the stored procedure.- Parameters:
procedureName
- The name of the procedure to call.args
- An ordered list of input arguments to be provided as input parameters to the procedure call.- Returns:
- list of output parameters, null on error.
-
onShutdown
void onShutdown()Called when transformer shuts down to close open connections and release acquired resources
-