Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql MyBatis数据映射。收集关系表_Mysql_Sql_Mybatis - Fatal编程技术网

Mysql MyBatis数据映射。收集关系表

Mysql MyBatis数据映射。收集关系表,mysql,sql,mybatis,Mysql,Sql,Mybatis,资金分配模板 模板id|模板名称|状态| 1百万乐透1 2 EZ-2 1 资金分配项目 |项目|项目|名称|状态| 1慈善机构1 2运营费用1 3食物津贴1 4交通津贴1 |5 |灾难受害者| 1| r\u模板项目 |模板标识项目标识项目百分比| 145.00 1255.00 21140.00 246.00 //FundAllocationTemplate.java(domain) private Integer templateID; private String templateName;

资金分配模板

模板id|模板名称|状态|

1百万乐透1

2 EZ-2 1

资金分配项目

|项目|项目|名称|状态|

1慈善机构1

2运营费用1

3食物津贴1

4交通津贴1

|5 |灾难受害者| 1|

r\u模板项目

|模板标识项目标识项目百分比|

145.00

1255.00

21140.00

246.00

//FundAllocationTemplate.java(domain)
private Integer templateID;
private String templateName;
private Integer templateStatus

//FundAllocationItem.java(domain)
private Integer itemID;
private String itemName;
private Integer itemStatus

<resultMap id="fundTemplate" type="FundAllocationTemplate">
    <id property="fundTemplateID"           column="template_id" />
    <result property="fundTemplateName"         column="template_name" />
    <result property="fundTemplateStatus"       column="status" />
    //Association for Status
</resultMap>

<resultMap id="fundItem" type="FundAllocationItem">
    <id property="fundItemID"       column="item_id" />
    <result property="fundItemName"     column="item_name" />
    <result property="fundItemStatus"   column="status" />
    //Association for Status
</resultMap>

FORM
private Integer templateID;
private String templateName;
private BigDecimal totalPercentage;
private Integer status;
//FundAllocationTemplate.java(域)
私有整数模板ID;
私有字符串模板名;
私有整数模板状态
//FundAllocationItem.java(域)
私有整数itemID;
私有字符串itemName;
私有整数项状态
//地位协会
//地位协会
形式
私有整数模板ID;
私有字符串模板名;
私人股本占总股本的百分比;
私有整数状态;
表单或页面输出 |分配模板名称|资金模板百分比|状态| |百万乐透| 100%|活跃|

|EZ-2 | 86%|有效|
问题:如何才能显示具有给定域和表设计的每个基金模板的总百分比?

使用以下查询:

select T.template_name,SUM(R.item_percentage) as Fund_Template_Percentage, 
(CASE T.status WHEN 1 THEN "Active" ELSE "NOT Active" END) STATUS 
from fund_allocation_template T, r_template_item R 
where T.template_id=R.template_id
GROUP BY R.template_id;

当我在MySql Workbench中运行它时,它会运行,但当我将它应用到我们的程序时,我遇到了一些错误,因为我们的域和结果映射中没有Fund_Template_百分比。您知道如何使用集合吗?您可以拥有一个resultType=“hashmap”,您将在java类中获得列表。对于每一行,您可以通过list.get(i).get(“基金模板百分比”)检索基金模板百分比,其中i是行号。