@@ -182,72 +182,77 @@ protected List<Object> extractResults(ResultSet resultSet) {
182
182
executionContext
183
183
);
184
184
185
- //noinspection unchecked
186
- final RowReader <Object > rowReader = (RowReader <Object >) ResultsHelper .createRowReader (
187
- executionContext ,
188
- null ,
189
- RowTransformerStandardImpl .INSTANCE ,
190
- null ,
191
- jdbcValues
192
- );
193
-
194
- /*
195
- * Processing options effectively are only used for entity loading. Here we don't need these values.
196
- */
197
- final JdbcValuesSourceProcessingOptions processingOptions = new JdbcValuesSourceProcessingOptions () {
198
- @ Override
199
- public Object getEffectiveOptionalObject () {
200
- return null ;
201
- }
185
+ try {
186
+ //noinspection unchecked
187
+ final RowReader <Object > rowReader = (RowReader <Object >) ResultsHelper .createRowReader (
188
+ executionContext ,
189
+ null ,
190
+ RowTransformerStandardImpl .INSTANCE ,
191
+ null ,
192
+ jdbcValues
193
+ );
202
194
203
- @ Override
204
- public String getEffectiveOptionalEntityName () {
205
- return null ;
206
- }
195
+ /*
196
+ * Processing options effectively are only used for entity loading. Here we don't need these values.
197
+ */
198
+ final JdbcValuesSourceProcessingOptions processingOptions = new JdbcValuesSourceProcessingOptions () {
199
+ @ Override
200
+ public Object getEffectiveOptionalObject () {
201
+ return null ;
202
+ }
207
203
208
- @ Override
209
- public Serializable getEffectiveOptionalId () {
210
- return null ;
211
- }
204
+ @ Override
205
+ public String getEffectiveOptionalEntityName () {
206
+ return null ;
207
+ }
212
208
213
- @ Override
214
- public boolean shouldReturnProxies () {
215
- return true ;
216
- }
217
- };
209
+ @ Override
210
+ public Serializable getEffectiveOptionalId () {
211
+ return null ;
212
+ }
218
213
219
- final JdbcValuesSourceProcessingStateStandardImpl jdbcValuesSourceProcessingState =
220
- new JdbcValuesSourceProcessingStateStandardImpl (
214
+ @ Override
215
+ public boolean shouldReturnProxies () {
216
+ return true ;
217
+ }
218
+ };
219
+
220
+ final JdbcValuesSourceProcessingStateStandardImpl jdbcValuesSourceProcessingState =
221
+ new JdbcValuesSourceProcessingStateStandardImpl (
222
+ executionContext ,
223
+ processingOptions
224
+ );
225
+ final ArrayList <Object > results = new ArrayList <>();
226
+ try {
227
+ final RowProcessingStateStandardImpl rowProcessingState = new RowProcessingStateStandardImpl (
228
+ jdbcValuesSourceProcessingState ,
221
229
executionContext ,
222
- processingOptions
230
+ rowReader ,
231
+ jdbcValues
223
232
);
224
- final ArrayList <Object > results = new ArrayList <>();
225
- try {
226
- final RowProcessingStateStandardImpl rowProcessingState = new RowProcessingStateStandardImpl (
227
- jdbcValuesSourceProcessingState ,
228
- executionContext ,
229
- rowReader ,
230
- jdbcValues
231
- );
232
233
233
- while ( rowProcessingState .next () ) {
234
- results .add ( rowReader .readRow ( rowProcessingState , processingOptions ) );
235
- rowProcessingState .finishRowProcessing ();
234
+ while ( rowProcessingState .next () ) {
235
+ results .add ( rowReader .readRow ( rowProcessingState , processingOptions ) );
236
+ rowProcessingState .finishRowProcessing ();
237
+ }
238
+ if ( resultSetMapping .getNumberOfResultBuilders () == 0
239
+ && procedureCall .isFunctionCall ()
240
+ && procedureCall .getFunctionReturn ().getJdbcTypeCode () == Types .REF_CURSOR
241
+ && results .size () == 1
242
+ && results .get ( 0 ) instanceof ResultSet ) {
243
+ // When calling a function that returns a ref_cursor with as table function,
244
+ // we have to unnest the ResultSet manually here
245
+ return extractResults ( (ResultSet ) results .get ( 0 ) );
246
+ }
247
+ return results ;
236
248
}
237
- if ( resultSetMapping .getNumberOfResultBuilders () == 0
238
- && procedureCall .isFunctionCall ()
239
- && procedureCall .getFunctionReturn ().getJdbcTypeCode () == Types .REF_CURSOR
240
- && results .size () == 1
241
- && results .get ( 0 ) instanceof ResultSet ) {
242
- // When calling a function that returns a ref_cursor with as table function,
243
- // we have to unnest the ResultSet manually here
244
- return extractResults ( (ResultSet ) results .get ( 0 ) );
249
+ finally {
250
+ rowReader .finishUp ( jdbcValuesSourceProcessingState );
251
+ jdbcValuesSourceProcessingState .finishUp ( results .size () > 1 );
252
+ jdbcValues .finishUp ( this .context .getSession () );
245
253
}
246
- return results ;
247
254
}
248
255
finally {
249
- rowReader .finishUp ( jdbcValuesSourceProcessingState );
250
- jdbcValuesSourceProcessingState .finishUp ( results .size () > 1 );
251
256
jdbcValues .finishUp ( this .context .getSession () );
252
257
}
253
258
}
0 commit comments