org.hibernate.procedure.ProcedureOutputsImpl tries to map all returned resultsets to the column set of the first resultset

Description

I have a stored procedure that returns different resultsets each consisting of different columns. I use an implementation object of ProcedureOutputs to retrieve each resultset consequtively using the method callOutputs.getCurrent() and callOutputs.goToNext() in a while loop. This first one is always retrieved without issues. The second one however will throw a `Column 'xyz' does not exist` error when the first resultset happens to contain a column xyz that it does not share with the second resultset retrieved. Only when the second and any other resultset after that have the exact same column set, with all columns arranged in the same order, no problems arise. But often this is not the case.

The bug is thus that hibernate tries to map any consecutive resultset to the same column set that existed in the first resultset. I don't know why it tries to do this. It reminds me of another functionality where Hibernate casts one resultset to a predefined entity. But it shouldn't do that here, because it is simply not instructed to do so.

Here are two threads on stackoverflow and dba that also report this problem.

https://stackoverflow.com/questions/24641818/using-jpa-with-stored-procedures-that-return-multiple-result-sets

https://dba.stackexchange.com/questions/265890/can-a-mysql-stored-procedure-return-multiple-resultsets-each-containing-differen?noredirect=1#comment523515_265890

Environment

Database: MySql 8.0, Hibernate 4.3.5

Assignee

Unassigned

Reporter

Maurice

Fix versions

None

Labels

None

backPortable

Backport?

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Minor
Configure