-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
<association> with Nested <collection> Returns Unexpected Results #1835
Comments
Hello @UserProgrammer , |
@harawata My bad. I had set it up as a private repo. It should be available now. |
Thank you for the update, @UserProgrammer , It seems like a simple misconfiguration issue.
MyBatis needs to know which column(s) to use to group these rows, so you need to declare <resultMap id="carOwnershipResultMap" type="com.example.entity.CarOwnership">
<id column="vehicle_id" /><!-- added -->
<association property="car" resultMap="carResultMap" />
<association property="user" resultMap="userResultMap" />
</resultMap> Note that With the above result map, the test passed on my environment. |
That worked! I thought the |
MyBatis version
3.4.6
Database vendor and version
mysql-connector-java:8.0.19
Test case or example project
https://github.com/UserProgrammer/mybatis-discriminator-example/tree/resultmap-bug-hunt
The relevant result-map xml configuration can be found in
src/main/resources/com/example/dao/CarDao.xml
The unit test is located at
src/test/java/com/example/dao/ICarDaoTest.java
database sql scripts are located at
sql-scripts/
Steps to reproduce
script/build
in the root project directory. (It'll take a few moments for the database docker container to be ready, you'll see a repeated message from mysqladmin. This is expected)Expected result
Actual result
Note that there are separate results for each serviceRecordId (for
car
withid = 1
), instead of having a single result where all the serviceRecordIds are collected in an array, as is expected:The text was updated successfully, but these errors were encountered: