Affects Version/s: 1.8.0
Fix Version/s: None
Component/s: SQL processing
Number of attachments :
I tried to get at the "Statement" that is used internally in Sql.execute() to read the ResultSet.
No luck. Not supported. This is a design issue.
Additionally, Source says "// TODO handle multiple results" (Sql.java, line 1339).
It's not even possible to get at a single ResultSet. Only the updateCount is exposed.
Subclassing Sql comes to mind, but that is not feasible. These methods do not lend themselves for overriding. The called methods, especially "getStatement()" and "getAbstractStatement(..)", "getPreparedStatement(...)" are all private (Arrrgh...).
Also, the default Statement pre-processing closure (configureStatement / void configure(Statement)) does not allow POST-processing of the Statement after the actual SQL call.
Solutions could be to
1. make the factory methods protected (not private)
2. add further postprocessStatement closure, to be called AFTER the execution. In that closure, the caller could read all ResultSets from the statement.
3. make configureStatement return a Statement (use original one on "null") so that the configure extension point can replace the statement.
I think that additional closure (2.) would be a good idea, since we'd be able
(a) to cut the TODO comment then (,
(b) leave the handling to the caller, and
(c) allow an extension point still within the transaction (before all is closed again)