@@ -114,7 +114,7 @@ private OracleR2dbcTypes() {}
114
114
* name.
115
115
* </p><p>
116
116
* The {@code ArrayType} object returned by this method may be used to create
117
- * a {@link Parameter} that binds an array value to a {@link Statement}.
117
+ * a {@link Parameter} that binds an array value to a {@link Statement}:
118
118
* </p><pre>{@code
119
119
* Publisher<Result> arrayBindExample(Connection connection) {
120
120
* Statement statement =
@@ -137,6 +137,39 @@ public static ArrayType arrayType(String name) {
137
137
return new ArrayTypeImpl (Objects .requireNonNull (name , "name is null" ));
138
138
}
139
139
140
+ /**
141
+ * <p>
142
+ * Creates an {@link ObjectType} representing a user defined {@code OBJECT}
143
+ * type. The {@code name} passed to this method must identify the name of a
144
+ * user defined {@code OBJECT} type.
145
+ * </p><p>
146
+ * Typically, the name passed to this method should be UPPER CASE, unless the
147
+ * {@code CREATE TYPE} command that created the type used an "enquoted" type
148
+ * name.
149
+ * </p><p>
150
+ * The {@code ObjectType} object returned by this method may be used to create
151
+ * a {@link Parameter} that binds an OBJECT value to a {@link Statement}:
152
+ * </p><pre>{@code
153
+ * Publisher<Result> objectMapBindExample(Connection connection) {
154
+ * Statement statement =
155
+ * connection.createStatement("INSERT INTO petTable VALUES (:petObject)");
156
+ *
157
+ * // Bind the attributes of the PET OBJECT defined above
158
+ * ObjectType objectType = OracleR2dbcTypes.objectType("PET");
159
+ * Map<String,Object> attributeValues = Map.of(
160
+ * "name", "Derby",
161
+ * "species", "Dog",
162
+ * "weight", 22.8,
163
+ * "birthday", LocalDate.of(2015, 11, 07));
164
+ * statement.bind("petObject", Parameters.in(objectType, attributeValues));
165
+ *
166
+ * return statement.execute();
167
+ * }
168
+ * }</pre>
169
+ * @param name Name of a user defined OBJECT type. Not null.
170
+ * @return A {@code Type} object representing the user defined OBJECT type.
171
+ * Not null.
172
+ */
140
173
public static ObjectType objectType (String name ) {
141
174
return new ObjectTypeImpl (Objects .requireNonNull (name , "name is null" ));
142
175
}
@@ -183,25 +216,32 @@ public interface ArrayType extends Type {
183
216
String getName ();
184
217
}
185
218
219
+ /**
220
+ * Extension of the standard {@link Type} interface used to represent user
221
+ * defined OBJECT types. An instance of {@code ObjectType} must be used when
222
+ * binding an OBJECT value to a {@link Statement} created by the Oracle R2DBC
223
+ * Driver.
224
+ */
186
225
public interface ObjectType extends Type {
187
226
188
227
/**
189
228
* {@inheritDoc}
190
- * Returns {@code Object[].class}, which is the standard mapping for
191
- * {@link R2dbcType#COLLECTION}. The true default type mapping is the array
192
- * variant of the default mapping for the element type of the {@code ARRAY}.
193
- * For instance, an {@code ARRAY} of {@code VARCHAR} maps to a
194
- * {@code String[]} by default.
229
+ * Returns the class of {@link OracleR2dbcObject}, which is the default mapping
230
+ * of OBJECT types returned by Oracle R2DBC.
195
231
*/
196
232
@ Override
197
233
Class <?> getJavaType ();
198
234
199
235
/**
200
236
* {@inheritDoc}
201
- * Returns the name of this user defined {@code ARRAY } type. For instance,
202
- * this method returns "MY_ARRAY " if the type is declared as:
237
+ * Returns the name of this user defined {@code OBJECT } type. For instance,
238
+ * this method returns "PET " if the type is declared as:
203
239
* <pre>{@code
204
- * CREATE TYPE MY_ARRAY AS ARRAY(8) OF NUMBER
240
+ * CREATE TYPE PET AS OBJECT(
241
+ * name VARCHAR(128),
242
+ * species VARCHAR(128),
243
+ * weight NUMBER,
244
+ * birthday DATE)
205
245
* }</pre>
206
246
*/
207
247
@ Override
0 commit comments