zoukankan      html  css  js  c++  java
  • Jpa查询记录

    占位符 单参数查询

    this.entityManager.createNativeQuery("SELECT statistical_date as statisticalDate, DATE_FORMAT(statistical_date, '%Y') AS year , insured_job_code as insuredJobCode,SUM(policy_daily_total) AS totalPolicy,SUM(policy_daily_price) AS insuFee " +
                            "FROM daily_policy_occupation " +
                            "WHERE customer_id = ? and insu_type = ? and statistical_date >= ? and statistical_date <= ? " +
                            "GROUP BY year,insuredJobCode order by year asc;")
                            .setParameter(1, ao.getCustomerId())
                            .setParameter(2, ao.getInsuType())
                            .setParameter(3, ao.getStartDate())
                            .setParameter(4, ao.getEndDate())
                            .unwrap(NativeQuery.class)
                            .setResultTransformer(Transformers.aliasToBean(YearlyOccupationInsuFeeVO.class))
                            .getResultList() 


    @Query("select new com.compass.dal.model.employer.DailyClaimClosedFeeModel(statisticalDate, sum(closedDailyCount), sum(closedDailyPrice) ,sum(dailyMedicineFee),sum(dailyDeathFee),sum(dailyDisabilityFee),sum(dailyDelayWorkFee),sum(dailyHospitalizationFee),sum(dailyOtherFee)) from DailyClaimFeeTypeDO where customerId = :customerId and statisticalDate >= :startDate and statisticalDate <= :endDate and insuType = :insuType group by statisticalDate order by  statisticalDate asc")
    List<DailyClaimClosedFeeModel> findByCustomerIdAndInsuTypeAndStatisticalDateBetweenOrderByStatisticalDateAsc(@Param("customerId") String customerId, @Param("insuType") String insuType, @Param("startDate") Date startDate, @Param("endDate") Date endDate);
     

    占位符多参数 指定参数名查询

    this.entityManager.createNativeQuery("SELECT statistical_date as statisticalDate, DATE_FORMAT(statistical_date, '%Y') AS year , insured_job_code as insuredJobCode,SUM(policy_daily_total) AS totalPolicy,SUM(policy_daily_price) AS insuFee " +
                            "FROM daily_policy_occupation " +
                            "WHERE customer_id = ? and insu_type = ? and statistical_date >= ? and statistical_date <= ? " +
                            "GROUP BY year,insuredJobCode order by year asc;")
                            .setParameter(1, ao.getCustomerId())
                            .setParameter(2, ao.getInsuType())
                            .setParameter(3, ao.getStartDate())
                            .setParameter(4, ao.getEndDate())
                            .unwrap(NativeQuery.class)
                            .setResultTransformer(Transformers.aliasToBean(YearlyOccupationInsuFeeVO.class))
                            .getResultList() 

    @Query("select new com.compass.dal.model.employer.DailyClaimClosedFeeModel(statisticalDate, sum(closedDailyCount), sum(closedDailyPrice) ,sum(dailyMedicineFee),sum(dailyDeathFee),sum(dailyDisabilityFee),sum(dailyDelayWorkFee),sum(dailyHospitalizationFee),sum(dailyOtherFee)) from DailyClaimFeeTypeDO where customerId in (:customerIds) and statisticalDate >= :startDate and statisticalDate <= :endDate and insuType = :insuType group by statisticalDate order by  statisticalDate asc")
    List<DailyClaimClosedFeeModel> findByCustomerIdsAndInsuTypeAndStatisticalDateBetweenOrderByStatisticalDateAsc(@Param("customerIds") List<String> customerIds, @Param("insuType") String insuType, @Param("startDate") Date startDate, @Param("endDate") Date endDate);

      

  • 相关阅读:
    Java中用Apache POI生成excel和word文档
    openlayers实现画圆
    openlayers实现wfs属性查询和空间查询
    jquery自定义控件拖拽框dragbox
    基于openlayers实现聚类统计展示
    openlayers实现在线编辑
    openlayers之selectfeature
    J
    HDU-1051Wooden Sticks
    HDU-1087Super Jumping! Jumping! Jumping!
  • 原文地址:https://www.cnblogs.com/cangshublogs/p/14950938.html
Copyright © 2011-2022 走看看