Named and unnamed rows
The JDBC 3.0 specification refers to an SQL type called a structured type or
struct, which is equivalent to the HCL
OneDB™ named row. The specification defines two
approaches to exchange structured-type data between a Java™
client and a relational database:
- Using the SQLData interface. A single Java class per named row type implements the SQLData interface. The class has a member for each element in the named row.
- Using the Struct interface. This interface instantiates the necessary Java object for each element in the named row and constructs an array of java.util.Object Java objects.
Whether HCL OneDB JDBC
Driver instantiates
a Java object or a Struct object
for a fetched named row depends on whether there is a customized type-mapping
entry or not, as follows:
- If there is an entry for a named row in the Connection.getTypeMap() map, or if you provided a type mapping using the getObject() method, a single Java object is instantiated.
- If there is no entry for a named row in the Connection.getTypeMap() map, and if you have not provided a type mapping using the getObject() method, a Struct object is instantiated.
Unnamed rows are always fetched into Struct objects.
Important: Regardless of whether you use the SQLData or Struct interface,
if a named or unnamed row contains an opaque data type column, there
must be a type-mapping entry for it. If you are using the Struct interface
to access a row that contains an opaque data type column, you need
a customized type map for the opaque data type column, but not for
the row as a whole.
For more information about custom type mapping, see Mapping data types.