public interface CassandraResultSetJsonSupport extends ResultSet
ResultSet interface providing additional methods specific to Cassandra result sets for
JSON-formatted results provided by Cassandra features SELECT JSON and toJson().
The CQL SELECT queries using JSON support will return a map where the keys are the column labels. So,
don't forget that if you use JSON formatting for only one column of type T, the result will be an object
like this one: { "columnLabel": { ... } } and should be deserialized to an object extending
Map<String, T> and not directly to T.
String and the collections can
be deserialized to List (for CQL types list, set and tuple) or Map (for CQL
types map and udt) of String items.
| CQL Type | JSON type | Acceptable Java types |
|---|---|---|
| ascii | string | String |
| bigint | integer | Number |
| blob | string | ByteBuffer |
| boolean | boolean | Boolean |
| date | string | Date, LocalDate |
| decimal | float | Number |
| double | float | Number |
| float | float | Number |
| inet | string | InetAddress |
| int | integer | Number |
| list | list | List |
| map | map | Map |
| set | list | Set, List |
| smallint | integer | Number |
| text | string | String |
| time | string | LocalTime |
| timestamp | string | OffsetDateTime |
| timeuuid | string | UUID |
| tinyint | integer | Number |
| tuple | list | List |
| udt | map | Map or a suitable object to which the map can be
deserialized |
| uuid | string | UUID |
| varchar | string | String |
| varint | integer | Number |
| vector | list | List |
CLOSE_CURSORS_AT_COMMIT, CONCUR_READ_ONLY, CONCUR_UPDATABLE, FETCH_FORWARD, FETCH_REVERSE, FETCH_UNKNOWN, HOLD_CURSORS_OVER_COMMIT, TYPE_FORWARD_ONLY, TYPE_SCROLL_INSENSITIVE, TYPE_SCROLL_SENSITIVE| Modifier and Type | Method and Description |
|---|---|
<T> T |
getObjectFromJson(Class<T> type)
Retrieves the value of the column labelled "
[json]", containing a JSON string, in the current row of
this ResultSet object as an instance of type T. |
<T> T |
getObjectFromJson(int columnIndex,
Class<T> type)
Retrieves the value of the designated column in the current row of this
ResultSet object as an instance
of type T from a JSON string. |
<T> T |
getObjectFromJson(String columnLabel,
Class<T> type)
Retrieves the value of the designated column in the current row of this
ResultSet object as an instance
of type T from a JSON string. |
absolute, afterLast, beforeFirst, cancelRowUpdates, clearWarnings, close, deleteRow, findColumn, first, getArray, getArray, getAsciiStream, getAsciiStream, getBigDecimal, getBigDecimal, getBigDecimal, getBigDecimal, getBinaryStream, getBinaryStream, getBlob, getBlob, getBoolean, getBoolean, getByte, getByte, getBytes, getBytes, getCharacterStream, getCharacterStream, getClob, getClob, getConcurrency, getCursorName, getDate, getDate, getDate, getDate, getDouble, getDouble, getFetchDirection, getFetchSize, getFloat, getFloat, getHoldability, getInt, getInt, getLong, getLong, getMetaData, getNCharacterStream, getNCharacterStream, getNClob, getNClob, getNString, getNString, getObject, getObject, getObject, getObject, getObject, getObject, getRef, getRef, getRow, getRowId, getRowId, getShort, getShort, getSQLXML, getSQLXML, getStatement, getString, getString, getTime, getTime, getTime, getTime, getTimestamp, getTimestamp, getTimestamp, getTimestamp, getType, getUnicodeStream, getUnicodeStream, getURL, getURL, getWarnings, insertRow, isAfterLast, isBeforeFirst, isClosed, isFirst, isLast, last, moveToCurrentRow, moveToInsertRow, next, previous, refreshRow, relative, rowDeleted, rowInserted, rowUpdated, setFetchDirection, setFetchSize, updateArray, updateArray, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateBigDecimal, updateBigDecimal, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateBoolean, updateBoolean, updateByte, updateByte, updateBytes, updateBytes, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateClob, updateClob, updateClob, updateClob, updateClob, updateClob, updateDate, updateDate, updateDouble, updateDouble, updateFloat, updateFloat, updateInt, updateInt, updateLong, updateLong, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNString, updateNString, updateNull, updateNull, updateObject, updateObject, updateObject, updateObject, updateObject, updateObject, updateObject, updateObject, updateRef, updateRef, updateRow, updateRowId, updateRowId, updateShort, updateShort, updateSQLXML, updateSQLXML, updateString, updateString, updateTime, updateTime, updateTimestamp, updateTimestamp, wasNullisWrapperFor, unwrap<T> T getObjectFromJson(int columnIndex,
Class<T> type)
throws SQLException
ResultSet object as an instance
of type T from a JSON string.
Typically, this method can be called on a result set returned by a CQL query like:
SELECT JSON col1, col2 FROM exampleTable;
or on a result column defined with the function toJson().
T - The type of the object represented by the JSON string.columnIndex - The column index (the first column is 1).type - The class representing the Java data type to convert the designated column to.T. If the value is SQL NULL, it should
return null.SQLException - if the columnIndex is not valid; if a database access error occurs; if this method is called
on a closed result set or if the value is cannot be parsed to an object of type T.<T> T getObjectFromJson(String columnLabel, Class<T> type) throws SQLException
ResultSet object as an instance
of type T from a JSON string.
Typically, this method can be called on a result set returned by a CQL query like:
SELECT JSON col1, col2 FROM exampleTable;
or on a result column defined with the function toJson().
T - The type of the object represented by the JSON string.columnLabel - The label for the column specified with the SQL AS clause. If the SQL AS clause was not
specified, then the label is the name of the column.type - The class representing the Java data type to convert the designated column to.T. If the value is SQL NULL, it should
return null.SQLException - if the columnIndex is not valid; if a database access error occurs; if this method is called
on a closed result set or if the value is cannot be parsed to an object of type T.<T> T getObjectFromJson(Class<T> type) throws SQLException
[json]", containing a JSON string, in the current row of
this ResultSet object as an instance of type T.
Typically, this method can be called on a result set returned by a CQL query like:
SELECT JSON * FROM exampleTable;
T - The type of the object represented by the JSON string.type - The class representing the Java data type to convert the column value to.T. If the value is SQL NULL, it should
return null.SQLException - if the columnIndex is not valid; if a database access error occurs; if this method is called
on a closed result set or if the value is cannot be parsed to an object of type T.Copyright © 2020–2024 ING Bank. All rights reserved.