我想将Guava multimap用作resultMap与MyBatis,以返回一个包含多个一对多条目的集合的结果集,但我无法弄清楚确切的语法。以下是我的表格样本:
+----+---------+----------+-------------+
| ID | PART_ID | NAME | PART_FAMILY |
+----+---------+----------+-------------+
| 1 | 1 | bush | 300 |
| 2 | 1 | a-bush | 300 |
| 3 | 1 | 300-bush | 300 |
| 4 | 2 | nut | 301 |
+----+---------+----------+-------------+
我想要一个结果集,以便我有一个以PART_ID为键的Guava多图,以及结果为NAME和PART_FAMILY。
例如:
Index 0 :
Key : 1 //PART_ID
Value : [NAME: bush, PART_FAMILY: 300]
Index 1 :
Key : 1
Value : [NAME: a-bush, PART_FAMILY: 300]
Index 2 :
Key : 1
Value : (NAME: 300-bush, PART_FAMILY: 300)
Index 3 :
Key : 2
Value : (NAME: nut, PART_FAMILY: 301)
以下是我的疑问:
<resultMap id="partsMap" type="com.google.common.collect.Multimap">
<id column="PART_ID" property="key" />
//Not sure what to put here
</resultMap>
<select id="getParts" resultMap="partsMap">
SELECT
PART_ID, NAME, PART_FAMILY
FROM PART_NAMES
WHERE ${filter}
ORDER BY PART_ID
</select>
我希望得到以下几点的帮助:
提前致谢!