-
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
When javaType
has not (or partially) been specified, determine the best matching constructor
#3378
base: master
Are you sure you want to change the base?
When javaType
has not (or partially) been specified, determine the best matching constructor
#3378
Conversation
…ry to determine the best matching constructor - falls back to current behaviour if any ambiguity is detected - remove setters from immutable `ResultMapping`
javaType
has not (or partially) been specified, determine the best matching constructorjavaType
has not (or partially) been specified, determine the best matching constructor
javaType
has not (or partially) been specified, determine the best matching constructorjavaType
has not (or partially) been specified, determine the best matching constructor
- Removed label outer: structure
The logic looks good, thank you! Is it possible to perform this after the search&sort by arg name step? mybatis-3/src/main/java/org/apache/ibatis/mapping/ResultMap.java Lines 136 to 146 in 1c21b8d
The reason we introduced the import java.time.LocalDate;
public record Account4(long accountId, String accountName, LocalDate accountDob) {
} <resultMap id="account4RM" type="org.apache.ibatis.submitted.auto_type_from_non_ambiguous_constructor.Account4">
<constructor>
<idArg name="accountId" column="id"/>
<!-- these two are defined in wrong order -->
<arg name="accountDob" column="dob" />
<arg name="accountName" column="name"/>
</constructor>
</resultMap>
<select id="getAccount4" resultMap="account4RM">
select id, name, type, date '2025-01-02' dob from account where id = #{id}
</select> I haven't given much thought, but you might have to move the search/sort logic out of |
As a related topic, I would like to provide a clear message when the |
That makes a lot of sense! I'll look into it, and add the suggested test case as well :) |
@harawata This ended up being way more involved than I thought. I discovered quite a lot of functionality, and a lot of interplay between them. The only way was to unify this for XML and annotations. We have multiple use-cases:
And I also tried to keep backward compatibility in mind. The resulting change is quite big; I will update shortly |
Yeah, it got complicated after #721 . The initial part of the determination process would look something like this (I only mention
It's been a while, so I could well be missing something obvious. |
@harawata I added all the test cases I could think of to |
7b3e6d2
to
e489d92
Compare
I'm really sorry, I accidentally rebased your branch on to master and force-pushed. 😰 Assuming you have the local branch |
e489d92
to
7b3e6d2
Compare
ResultMapping