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