Package com.caplin.jtm.persistence
Interface Persistence
public interface Persistence
Provides access to the Transformer persistence service.
If a module uses the persistence service any data persisted is saved over restarts of Transformer and - if a central database is used - is also available on multiple Transformers is they are clustered together.
-
Method Summary
Modifier and TypeMethodDescriptionCalls a stored procedure in the persistence serviceint
Deletes entries from the persistence service given the provided selectorGets entries from the persistence service given the provided selectorquery
(String table, String query, QueryParams params) Gets entries from the persistence service matching the provided queryint
Updates or inserts an entry to be stored by the persistence service
-
Method Details
-
upsert
int upsert(String table, Map<String, String> keys, Map<String, throws PersistenceExceptionString> data) Updates or inserts an entry to be stored by the persistence service- Parameters:
table
- The name of the table used for persistencekeys
- keys The key value pairs are used for building the WHERE clause of the SQL query, where key='value' for each key-value pair.data
- Key value pairs representing the field names and their values to be set on the 'upsertion'- Returns:
- The number of entries affected by the update / insertion
- Throws:
PersistenceException
- when the upsert fails
-
get
- Parameters:
selector
-query(String, String, QueryParams)
table
-query(String, String, QueryParams)
limit
defaults to 0 - no limitordering
defaults to null - no ordering- Returns:
query(String, String, QueryParams)
- Throws:
PersistenceException
- if the persistence get fails- See Also:
-
get
List<Map<String,String>> get(String table, Map<String, String> selector, long limit) throws PersistenceException- Parameters:
table
-query(String, String, QueryParams)
selector
-query(String, String, QueryParams)
limit
-query(String, String, QueryParams)
ordering
defaults to null - no ordering- Returns:
query(String, String, QueryParams)
- Throws:
PersistenceException
- if the persistence get fails- See Also:
-
get
List<Map<String,String>> get(String table, Map<String, String> selector, LinkedHashMap<String, throws PersistenceExceptionOrdering> ordering) - Parameters:
selector
-query(String, String, QueryParams)
ordering
-query(String, String, QueryParams)
table
-query(String, String, QueryParams)
limit
defaults to 0 - no limit- Returns:
query(String, String, QueryParams)
- Throws:
PersistenceException
- if the persistence get fails- See Also:
-
get
List<Map<String,String>> get(String table, Map<String, String> selector, LinkedHashMap<String, throws PersistenceExceptionOrdering> ordering, long limit) Gets entries from the persistence service given the provided selector- Parameters:
table
- The name of the table used for persistenceselector
- Key value pairs representing field names to field values. These are used for constructing the WHERE clause of the SELECT query, where the value for each given field name is matched against the field value.ordering
- LinkedMap specifying the ordering criteria for this query in priority order. First element returned via iterating over this map represents the primary sort column. Null for database sort order.limit
- Limits the number of rows returned by this query. The firstlimit
rows with respect to the sort order will be returned, 0 for no limit- Returns:
- The rows matching the selector. This consists of a Java List of Maps. Each Map represents a row (key value pairs corresponding to field names and their values). The List is empty if no rows match the search query.
- Throws:
PersistenceException
- if the persistence get fails Note: This method is a convenience wrapper forquery(String, String, QueryParams)
- See Also:
-
query
List<Map<String,String>> query(String table, String query, QueryParams params) throws PersistenceException Gets entries from the persistence service matching the provided query- Parameters:
table
- The name of the table used for persistencequery
- Used as the predicate for the WHERE clause when constructing an SQL query. The query should be formatted as a JDBC Prepared Statement using '?' placeholders.params
-QueryParams
to specify arguments to be bound to '?' characters in the query string, custom sort criteria and a 'limit' specifying the maximum number of rows to be returned- Returns:
- The rows matching the selector. This consists of a Java List of Maps. Each Map represents a row (key value pairs corresponding to field names and their values). The List is empty if no rows match the search query.
- Throws:
PersistenceException
- if the persistence query fails.
-
delete
Deletes entries from the persistence service given the provided selector- Parameters:
table
- The name of the table used for persistenceselector
- Key value pairs representing field names to field values. These are used for constructing the WHERE clause of the SELECT query, where the value for each given field name is matched against the field value.- Returns:
- The number of rows deleted
- Throws:
PersistenceException
- if the persistence delete fails.
-
call
Calls a stored procedure in the persistence service- Parameters:
procedure
- The name of the procedure to be calledargs
- An ordered list of input arguments to be provided as input parameters to the procedure call.- Returns:
- The output parameters. Keys are always uppercase for DBMS independence.
- Throws:
PersistenceException
- if the procedure call fails.
-