1.自定义vo类接收多个实体数据时,返回数据是list集合的
1.1 service 业务层
@Override
public List<Map<String,EnterpriseFiscalVo>> getDistrictCounty() {
List<Map<String,EnterpriseFiscalVo>> list = enterpriseFiscalRepository.getDistrictCounty();
return list;
}
1.2 repository 层
@Query(value = "select \n" +
"sum(elect.value) as electValue ,\n" +
"sum(fiscal.output_value) as monthValue ,\n" +
"fiscal.year as years,\n" +
"fiscal.months as months ,\n" +
"sum(fiscal.trade_income) as tradeIncome \n" +
"from enterprise enterprise \n" +
"left join enterprise_fiscal fiscal on fiscal.enterprise_id = enterprise.id \n" +
"left join enterprise_elect elect on elect.enterprise_id = enterprise.id \n" +
"group by months , years \n" +
"order by months , years desc",nativeQuery = true)
List<Map<String,EnterpriseFiscalVo>> getDistrictCounty();
2.yml配置
spring:
jpa:
hibernate:
#create 每次运行程序,没有表格会新建表格,表格内数据会清空
#create-drop 每次运行结束的时候回清空表
#update 每次运行程序,没有表格会新建表格,没有表格不会清空,只会更新
#validate 每次运行程序会效验数据与数据库字段类型是否相同,不同会报错
ddl-auto: validate文章来源:https://www.toymoban.com/news/detail-693669.html#是否输出SQL,工作台里面是否输出
show-sql: false
open-in-view: false文章来源地址https://www.toymoban.com/news/detail-693669.html
到了这里,关于jpa框架部分重点的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!