class Member {
Integer id;
String name;
List<ClubRegistration> clubRegistrations;
}
class Club {
Integer id;
String name;
List<MemberRegistration> memberRegistrations;
}
class ClubRegistration {
Club club;
Date date;
}
class MemberRegistration {
Member member;
Date date;
}
以便您可以通过两种方式获取数据:会员与其俱乐部或俱乐部与其会员。 SQL查询:
SELECT m.id AS memberId, m.name AS memberName, c.id AS clubId, c.name AS clubName, register_Date
FROM member m
INNER JOIN member_club mc ON m.id = mc.member_id
INNER JOIN club c ON mc.club_id = c.id
WHERE {what you want}
1条答案
按热度按时间hgncfbus1#
下面是我推荐的对象模型:
以便您可以通过两种方式获取数据:会员与其俱乐部或俱乐部与其会员。
SQL查询:
您所问案例的ResultMap:
只需将会员/俱乐部换成另一个案例即可。
然后,您甚至应该引用resultMap而不是nest define:
虽然我没有亲自检查过the circular reference issue that would arise is managed bay MyBatis。