1

编辑:简单地说,我想将动态列分组到 pojo 中的地图中。

我想使用 ibatis 读取 pojos 列表,但 pojo 包含我必须阅读的地图:

public class FundraiserSuccessData {
private String regionName;
private String fundraiserName;
// Key: Attendance ID, Value: Count
private Map<Integer, Integer> attendanceCount;
...
}

目前我会读取考勤类型并将类型作为列表放在 ibatis 查询的参数中。

<select id="fundraiserSuccessReport.search" resultClass="controller.report.fundraiserSuccess.FundraiserSuccessData" parameterClass="controller.report.fundraiserSuccess.SearchRequest">

SELECT VALUE(MAX(r.name), 'D2D') regionName,
       MAX(fr.firstname) || ' ' || MAX(fr.lastname) AS fundraiserName,
       <iterate property="attendanceTypes" conjunction=","> MAX(attendance.$attendanceTypes[]$) $attendanceTypes[]$ </iterate>
...
JOIN (SELECT dps.person_id,
            <iterate property="attendanceTypes" conjunction=","> 
             SUM(CASE WHEN attendance_id = $attendanceTypes[].id$ THEN 1 ELSE 0 END) $attendanceTypes[].name$
             </iterate>
    FROM daily_person_state dps
    GROUP BY dps.person_id) attendance
    ON fr.id = attendance.person_id
...
</select>

但是我怎样才能将加入映射到出席人数?因为我无法向 java 添加动态属性。

4

0 回答 0