Fetching multiple result sets
Some RDBMSs (for instance, SQL Server and MySQL after appending the allowMultiQueries=true property to the JDBC URL) can return multiple result sets. Here is such a jOOQ query for MySQL:
ctx.resultQuery( "SELECT * FROM employee LIMIT 10; SELECT * FROM sale LIMIT 5");
To fetch multiple result sets in jOOQ, call fetchMany(). This method returns an object of the org.jooq.Results type, as shown in the following snippet (notice the pluralization to avoid any confusion with org.jooq.Result):
Results results = ctx.resultQuery( "SELECT * FROM employee LIMIT 10; SELECT * FROM sale LIMIT 5") .fetchMany();
Next, you can map each result set to its POJO:
List<Employee> employees =results.get(0).into(Employee.class); List<Sale> sales = results.get(1).into(Sale.class);
Lukas Eder says:
"Perhaps out of scope, but...