One to many queries , One message corresponds to multiple data , We use collections to store data from multiple parties . Use resultMap Tag to define the format of the encapsulation , In the test today , Only one piece of data is encapsulated in the set .
After consulting the information, we know that , Because both tables have id Field , But they didn't explain why , I didn't go into it , But the guess should be because the result set of the query has two id Field ,mybatis Put the main table's id Values are also stored in the id Field
When reading the first line of data, because I'm not sure if there is this one behind id Line return for ,mybatis The first line will exist Cahce Class , When reading the second line ,mybatis Judge sub table id The values are found to be the same , You think it's the same data .
To one of them id Add an alias to the field