stored-procedure-proxy icon indicating copy to clipboard operation
stored-procedure-proxy copied to clipboard

Multiple ResultSet Extraction

Open jorge-lavin opened this issue 6 years ago • 5 comments

Does this library support for multiple result handling? For SQL Server stored procedures

Thanks

jorge-lavin avatar Dec 20 '19 10:12 jorge-lavin

No, it currently does not. Is this a use case you have? if so, can you tell me more about your use case? Are your result sets homogeneous?

marschall avatar Dec 22 '19 11:12 marschall

Yes, it is a use case I have, it may be out of scope for this library. The result sets are not homogeneous. In the single use case I have in mind there are like 5. Its a hand made stored procedure

The code for building the objects is quite bloated, but may work with slight modifications on my classes and something along the lines of as many value extractors as result sets.

jorge-lavin avatar Dec 23 '19 09:12 jorge-lavin

The result sets are not homogeneous.

That's what I feared. Could you provide a bit more detail how the values in the different result sets are related and how they contribute to the final return value? Just guessing but it sounds like your use case could be similar to supporting multiple out parameters. One of the reasons multiple out parameters are currently not supported is because the most natural way to support them would be tuples. As the Java standard library does not provide tuple classes we would have to introduce our own. This would then create a dependency from the calling code to this library. This is something I would like to avoid.

marschall avatar Dec 23 '19 19:12 marschall

Yes i have a main business entity thas some one to many relationships. One of them is represented by a user defined type in a SQL Server.

Lets call the (type of) main entity M and for child entities C1, C2 and C3.

There is a hierarchy:

  • I need C3 to build C2
  • Both C2 and C3 to build C1
  • All three of them to build M

I may suffice to have an ordered structure of extractors and apply them in order to the result sets of the SP

Thanks for your valuable time.

jorge-lavin avatar Dec 24 '19 10:12 jorge-lavin

That doesn't sound easy to support out of the box. Things that come to mind how it could be solved:

  • "join in Java" meaning first you select from C1, C2 and C3 individually, then probably into Maps or similar and finally build M in Java using Map lookups
  • "join in SQL" meaning you write a second stored procedure that joins C1, C2, C3, then you could use a ValueExtractor to map the SQL rows to Java rows and then finally in Java map the rows to Ms by accessing the previous rows.

I all cases it's questionable this library buys you much over writing straight JDBC code.

marschall avatar Dec 25 '19 21:12 marschall