-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Support for associations and collections filled with multiple result sets #27
Conversation
are taken for current record, thay may be a parent or a child
From the dev list: "We have been discussing this feature off-line. Let me provide the I do agree with Iwao in that probably this feature can be used in such But, it can be really useful for stored procs that return more than I will try this way to see where it gets and let you know." |
Patch applied in fd34445 |
This change has broken a significant code basis for us, which we now have to migrate because of this backward incompatibility. Why simply a new Annotation? How many really need a List of resultMap? |
Hello @chhex , This feature is crucial for a stored procedure that returns multiple result sets. I'm wondering how this change could break backward compatibility. Could you elaborate? |
Hey @harawata Because of the large Code Basis we have, and the Mapper Files being in many different jars, we load and parse the Mapper Interfaces dynamically with the Mybatis Configuration API. I could look up the details. This worked fine up-to 3.2.2. With this change we get a Java Type Error upon parsing the ResultSet Annotation:
kind of understandable, isn’t it? Yes a String Array isn’t a String, maybe in some scenarios, you look a String as a single String in a String vararg, but clearly from Type Declaration resp Annotation point of view the two are different. This could have be avoided with for example a new Annotation, which it effectively is from a Java point view. Or have the same Annotation with two arguments, a String and a String Array , whatever. Importance / Criticality is always realative, specially in Software Engineering. Thanks! |
Hello @chhex , Thank you for the explanation! The change (i.e. replacing FYI, for recent versions, we list backward incompatible changes in the release note when there is any, but there may be some unlisted changes that break binary-code compatibility. |
Hi.
The purpose of this change is adding support for filling associations and collections out of multiple result sets. (see issue #512 in gcode)
Suppose we have the tipical N+1 problem: An order that has order lines.
Right now MyBatis provides two ways of solving this.
Both work but have their drawbacks.
The proposal is to add the third way:
First, two sentences are sent to the database at the same time.
Which causes an execution like this one:
Note that MyBatis already supports multiple resultsets with this notation:
This will produce a List with two lists, each one filled with one type of object (Order, OrderDetail) and no relationships between them.
In order to crate a full object graph I am proposing to include some new attributes in the associations or collection elements:
And another one in the statement:
For the suspicious, this is not ORM at all. The intention is not to map objects to tables but to resultsets.
What do you think?