public interface CassandraStatementJsonSupport extends PreparedStatement
PreparedStatement interface providing additional methods specific to Cassandra statements using
JSON features INSERT INTO ... JSON and fromJson().
String
(be careful with the format to use for some CQL types like dates for example) and the collections can contain
String items.
| CQL Type | Accepted JSON types | Acceptable Java types |
|---|---|---|
| ascii | string | String |
| bigint | integer, string | Integer, BigInteger |
| blob | string | ByteBuffer, String (should be an
even-length hexadecimal representation of the blob bytes starting with '0x') |
| boolean | boolean, string | Boolean |
| date | string | Date, LocalDate |
| decimal | integer, float, string | Number |
| double | integer, float, string | Number |
| float | integer, float, string | Number |
| inet | string | InetAddress |
| int | integer, string | Integer |
| list | list, string | List |
| map | map, string | Map |
| set | list, string | Set, List |
| smallint | integer, string | Short |
| text | string | String |
| time | string | LocalTime |
| timestamp | integer, string | Integer, OffsetDateTime |
| timeuuid | string | UUID |
| tinyint | integer, string | Byte |
| tuple | list, string | List |
| udt | map, string | Map or a suitable object serializable
and matching the target UDT |
| uuid | string | UUID |
| varchar | string | String |
| varint | integer, string | Integer, BigInteger |
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO| Modifier and Type | Method and Description |
|---|---|
<T> void |
setJson(int parameterIndex,
T x)
Sets the value of the designated parameter with the given object converted to a JSON string.
|
addBatch, clearParameters, execute, executeLargeUpdate, executeQuery, executeUpdate, getMetaData, getParameterMetaData, setArray, setAsciiStream, setAsciiStream, setAsciiStream, setBigDecimal, setBinaryStream, setBinaryStream, setBinaryStream, setBlob, setBlob, setBlob, setBoolean, setByte, setBytes, setCharacterStream, setCharacterStream, setCharacterStream, setClob, setClob, setClob, setDate, setDate, setDouble, setFloat, setInt, setLong, setNCharacterStream, setNCharacterStream, setNClob, setNClob, setNClob, setNString, setNull, setNull, setObject, setObject, setObject, setObject, setObject, setRef, setRowId, setShort, setSQLXML, setString, setTime, setTime, setTimestamp, setTimestamp, setUnicodeStream, setURLaddBatch, cancel, clearBatch, clearWarnings, close, closeOnCompletion, execute, execute, execute, execute, executeBatch, executeLargeBatch, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getLargeMaxRows, getLargeUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, isClosed, isCloseOnCompletion, isPoolable, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setLargeMaxRows, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeoutisWrapperFor, unwrap<T> void setJson(int parameterIndex,
T x)
throws SQLException
Typically, this method can be called to bind a JSON parameter in a CQL query like:
INSERT INTO exampleTable JSON ?;
or on a specific column using with the function fromJson():
INSERT INTO exampleTable (item) VALUES (fromJson(?));
T - The type of the original object before conversion to a JSON string.parameterIndex - The parameter index (the first parameter is 1).x - The object containing the input parameter value.SQLException - if the parameter index does not correspond to a parameter marker in the SQL statement; if a
database access error occurs; if this method is called on a closed PreparedStatement
or if the object specified by x cannot be converted into a valid JSON string.Copyright © 2020–2024 ING Bank. All rights reserved.