Class UpsertJsonObject
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,ConfigComment
,ConnectedService
,MessageEventGenerator
,Service
,StateManagedComponent
- Direct Known Subclasses:
UpsertJsonObjects
Creates an insert or update statement based on the contents of the JSON object.
{ "firstname":"carol", "lastname":"smith", "dob":"2017-01-03", "id": "1234"}
will effectively execute the following statement INSERT INTO table (firstname,lastname,dob,id) VALUES (?,?,?,?)
or
UPDATE table SET firstname=?, lastname=?, dob=? WHERE id = ?;
if 1234
already exists as a row.
Note that no parsing/assertion of the column names will be done, so if they are invalid SQL columns then it's going to be
fail. Additionally, nested JSON objects will be rendered as strings before being passed into the appropriate statement; so
{ "firstname":"alice", "lastname":"smith", "address": { "address" : "Buckingham Palace", "postcode":"SW1A 1AA"}}
would
still be 3 parameters, the address parameter will be '{ "address" : "Buckingham Palace", "postcode":"SW1A 1AA"}'
- Since:
- 3.6.5
In the adapter configuration file this class is aliased as json-jdbc-upsert which is the preferred alternative to the fully qualified classname when building your configuration.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.adaptris.core.services.jdbc.JdbcMapUpsert
JdbcMapUpsert.SelectWrapper, JdbcMapUpsert.UpdateWrapper
Nested classes/interfaces inherited from class com.adaptris.core.services.jdbc.JdbcMapInsert
JdbcMapInsert.BasicType, JdbcMapInsert.InsertWrapper, JdbcMapInsert.StatementParam, JdbcMapInsert.StatementWrapper
-
Field Summary
Fields inherited from class com.adaptris.core.services.jdbc.JdbcMapUpsert
DEFAULT_ID_FIELD
Fields inherited from class com.adaptris.core.ServiceImp
log
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
doService
(AdaptrisMessage msg) void
Specify the behaviour when aNullNode
is encountered.Methods inherited from class com.adaptris.core.services.jdbc.JdbcMapUpsert
getIdField, handleUpsert, idField, setIdField, withId
Methods inherited from class com.adaptris.core.services.jdbc.JdbcMapInsert
addUpdatedMetadata, buildStatementParam, closeJdbcService, columnBookend, getColumnBookendCharacter, getFieldMappings, getRowsAffectedMetadataKey, getTable, handleInsert, initJdbcService, prepareService, setColumnBookendCharacter, setFieldMappings, setRowsAffectedMetadataKey, setTable, startService, stopService, table, withColumnBookend, withMappings, withRowsAffectedMetadataKey, withTable
Methods inherited from class com.adaptris.core.jdbc.JdbcService
applyTimeout, closeService, createStatement, getConnection, getConnection, getStatementTimeout, initService, prepare, prepareStatement, prepareStatement, setConnection, setStatementTimeout, start, stop
Methods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, createName, createQualifier, getComments, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setComments, setContinueOnFail, setIsTrackingEndpoint, setUniqueId
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.adaptris.core.AdaptrisComponent
getUniqueId
Methods inherited from interface com.adaptris.core.ComponentLifecycle
close, init
Methods inherited from interface com.adaptris.core.ConfigComment
getComments, setComments
Methods inherited from interface com.adaptris.core.MessageEventGenerator
createName, createQualifier, isTrackingEndpoint
Methods inherited from interface com.adaptris.core.Service
continueOnFailure, isBranching, setUniqueId
Methods inherited from interface com.adaptris.core.StateManagedComponent
changeState, requestClose, requestInit, requestStart, requestStop, retrieveComponentState
-
Constructor Details
-
UpsertJsonObject
public UpsertJsonObject()
-
-
Method Details
-
doService
- Throws:
ServiceException
-
getNullConverter
- Returns:
- the nullConverter
-
setNullConverter
Specify the behaviour when aNullNode
is encountered.- Parameters:
nc
- the NullConverter to set, the default is effectively the string"null"
as returned byNullNode#asText()
-