Hibernate: Multiple Result Sets

5.4k views Asked by At

from what I've read in the Hibernate documentation/online it sounds like Hibernate does not have the ability to handle multiple result sets. I'm looking to make a MySQL DB call in an application that relies on Hibernate, that will return multiple result sets.

What solutions have you used that "play well" with Hibernate, keeping in mind it's likely this will be the only call where multiple result sets will be returned?

Thanks!

3

There are 3 answers

5
Bozho On BEST ANSWER

AFAIK, you can't handle multiple result sets with hibernate. But I don't think you need it - multiple result sets can rarely map to results like List<FooEntity>. You can use plain JDBC for the queries that return multiple result sets and handle them manually.

0
javamonkey79 On

I am sure you already have seen this @Ryan, but for sake of someone else (like me):

For Sybase or MS SQL server the following rules apply:

The procedure must return a result set. Note that since these servers can return multiple result sets and update counts, Hibernate will iterate the results and take the first result that is a result set as its return value. Everything else will be discarded.

From here.

0
Maurice On

If the resultsets are coming from a stored procedure it is possible to get them using the javax.persistence.StoredProcedureQuery class. Make sure though that all resultsets consist of the exact same columns in the same order. A bug in hibernate causes it to expect all the resultsets to have the same form as the first resultset.