Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple ResultSet Extraction #67

Open
jorge-lavin opened this issue Dec 20, 2019 · 5 comments
Open

Multiple ResultSet Extraction #67

jorge-lavin opened this issue Dec 20, 2019 · 5 comments

Comments

@jorge-lavin
Copy link

jorge-lavin commented Dec 20, 2019

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

Thanks

@marschall
Copy link
Owner

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?

@jorge-lavin
Copy link
Author

jorge-lavin commented Dec 23, 2019

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.

@marschall
Copy link
Owner

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.

@jorge-lavin
Copy link
Author

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.

@marschall
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants