The Association of objects, especially Manytoone, has two ways: send an extra SQL to query and inline the way
Send an extra SQL: When I use this associated object, I send an extra SQL to query the associated object, and then set it inside the object, which can easily cause n+1 problems.
Inline mode: In this SQL directly connected to the object of the table to join in, the need to query the information all out, and then directly in the Resultmap to assemble the associated objects, so you can avoid n+1 problems, but will cause the performance loss of the connection
Selection principle:
If the associated object is to be displayed in the list, the performance loss associated with the table can be caused directly by using inline
If you want to view this object, then choose how to send an extra SQL query, but it will cause n+1 problems
Which way do you choose?
Choose to send an extra SQL
Because the borrower's information is not displayed in the list, but when we are going to look at the borrower's information, when we are going to check out the details of his loan, we will go to see his information, this property to see an object is displayed.
The notation of association in Mapper.xml
Using the Send extra SQL query, the following SQL statement does not change
The question of optimistic locking
N+1 problem, online search for resources
Association of objects in Mapper.xml