Skip to content

Commit 955602b

Browse files
ngocnhan-tran1996snicoll
authored andcommitted
Stop referring to STRUCT and ARRAY as they are deprecated
See gh-33248
1 parent b626622 commit 955602b

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

framework-docs/modules/ROOT/pages/data-access/jdbc/parameter-handling.adoc

+13-14
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ Java::
222222
223223
public TestItemStoredProcedure(DataSource dataSource) {
224224
// ...
225-
declareParameter(new SqlOutParameter("item", OracleTypes.STRUCT, "ITEM_TYPE",
225+
declareParameter(new SqlOutParameter("item", Types.STRUCT, "ITEM_TYPE",
226226
(CallableStatement cs, int colIndx, int sqlType, String typeName) -> {
227-
STRUCT struct = (STRUCT) cs.getObject(colIndx);
227+
Struct struct = (Struct) cs.getObject(colIndx);
228228
Object[] attr = struct.getAttributes();
229229
TestItem item = new TestItem();
230230
item.setId(((Number) attr[0]).longValue());
@@ -258,8 +258,8 @@ Kotlin::
258258
You can use `SqlTypeValue` to pass the value of a Java object (such as `TestItem`) to a
259259
stored procedure. The `SqlTypeValue` interface has a single method (named
260260
`createTypeValue`) that you must implement. The active connection is passed in, and you
261-
can use it to create database-specific objects, such as `StructDescriptor` instances
262-
or `ArrayDescriptor` instances. The following example creates a `StructDescriptor` instance:
261+
can use it to create database-specific objects, such as `java.sql.Struct` instances
262+
or `java.sql.Array` instances. The following example creates a `java.sql.Struct` instance:
263263

264264
[tabs]
265265
======
@@ -272,14 +272,12 @@ Java::
272272
273273
SqlTypeValue value = new AbstractSqlTypeValue() {
274274
protected Object createTypeValue(Connection conn, int sqlType, String typeName) throws SQLException {
275-
StructDescriptor itemDescriptor = new StructDescriptor(typeName, conn);
276-
Struct item = new STRUCT(itemDescriptor, conn,
277-
new Object[] {
275+
var item = new Object[] {
278276
testItem.getId(),
279277
testItem.getDescription(),
280278
new java.sql.Date(testItem.getExpirationDate().getTime())
281-
});
282-
return item;
279+
};
280+
return connection.createStruct(typeName, item);
283281
}
284282
};
285283
----
@@ -307,7 +305,7 @@ You can now add this `SqlTypeValue` to the `Map` that contains the input paramet
307305
Another use for the `SqlTypeValue` is passing in an array of values to an Oracle stored
308306
procedure. Oracle has its own internal `ARRAY` class that must be used in this case, and
309307
you can use the `SqlTypeValue` to create an instance of the Oracle `ARRAY` and populate
310-
it with values from the Java `ARRAY`, as the following example shows:
308+
it with values from the Java `java.sql.Array`, as the following example shows:
311309

312310
[tabs]
313311
======
@@ -319,9 +317,7 @@ Java::
319317
320318
SqlTypeValue value = new AbstractSqlTypeValue() {
321319
protected Object createTypeValue(Connection conn, int sqlType, String typeName) throws SQLException {
322-
ArrayDescriptor arrayDescriptor = new ArrayDescriptor(typeName, conn);
323-
ARRAY idArray = new ARRAY(arrayDescriptor, conn, ids);
324-
return idArray;
320+
return conn.unwrap(OracleConnection.class).createOracleArray(typeName, ids);
325321
}
326322
};
327323
----
@@ -345,5 +341,8 @@ Kotlin::
345341
----
346342
======
347343

348-
344+
[NOTE]
345+
====
346+
Use `unwrap(OracleConnection.class)` method if connection is not an OracleConnection's instance
347+
====
349348

0 commit comments

Comments
 (0)