• atitit. 统计功能框架的最佳实践(1)---- on hibernate criteria


    atitit. 统计功能框架的最佳实践(1)---- on hibernate criteria 

    1. 关键字 1

    2. 统计功能框架普通有有些条件选项...一个日期选项..一个日期类型(,,月份,年等) 1

    3. 元数据的位置,不需要绑定class 1

    4. 设置聚合字段... @reduce(" sum(timLen) "),@reduce(" Avg(timLen) ") 2

    5. 设置groupby  字段  @GroupBy 2

    6. 设置groupbydate  字段  @GroupBydate 3

    7. Where设置@condition 3

    8. 实现查询 ,,不能返回class,子能list<map> 3

    9. 子对象关联 @CountRelt(uiFld="groupid",fld="departId") 3

    1. 关键字

    Hibernate criteria 日期groupby  子对象属性groupby

    2. 统计功能框架普通有有些条件选项...一个日期选项..一个日期类型(,,月份,年等)

    作者:: 老哇的爪子 Attilax 艾龙,  EMAIL:1466519819@qq.com

    转载请注明来源: http://blog.csdn.net/attilax

    3. 元数据的位置,不需要绑定class

    统计的list结果是不绑定class,,走十一个List(map>

    中间,元数据放的个拉李都行了...

    不过,放得个html黑头还要解释器了....使用注解实现走马中个麻烦的...林吧,还是使用注解实现兰...

    4. 设置聚合字段... @reduce(" sum(timLen) "),@reduce(Avg(timLen) ")

    private Integer timLen;

     

    5. 设置groupby  字段 @GroupBy

    @GroupBy

    @CountRelt(uiFld="groupid",fld="departId")

    Equipment eq;

     

    解释器实现

    Criteria c = new BaseSvs().getSession().createCriteria(this.saveObjClass);

    Criteria eqCri = c.createAlias("eq", "equ", JoinType.LEFT_OUTER_JOIN);

    if(this.reqMap.get("groupid")!=null && this.reqMap.get("groupid").toString().trim().length()>0 )

    {

    //Projections.groupProperty(propertyName) 

    projectionList1.add(  Projections.groupProperty("equ.departId").as("departId"));

    projectionList1.add(  Projections.groupProperty("equ.equipmentId").as("equipmentId"));

    //projectionList1.add(  Projections.groupProperty("equ.mome").as("mome"));

    int grpid = Integer.parseInt(   this.reqMap.get("groupid").toString());

    eqCri.addRestrictions.eq("equ.departId", grpid));

    }

     

    6. 设置groupbydate  字段 @GroupBydate

     

    或者不个这个弄个自定义的fmtr比较好的.....不过这个date雅十通常使用的,,spetion弄个中个注解也行了...

     

    解释器实现

     

    projectionList1.add(Projections.sqlGroupProjection(" count(*) as shouldDown, count(*) as actDown,  CONVERT(varchar(10), download_create_time ,23 ) as timRang ", "  CONVERT(varchar(10), download_create_time ,23 ) ", new String[] { "shouldDown", "actDown", "timRang" }, new Type[] { IntegerType.INSTANCE, IntegerType.INSTANCE, StringType.INSTANCE }));

     

    7. Where设置@condition

    留意子对象属性conditon 的设置...

    8. 实现查询 ,,不能返回class,子能list<map>

    不官十使用criteria ,还是sql ,都子能回归mapList,,...还以为criteria能回归class...

      Criteria cri=getCriteria();

        cri.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);

    List list=cri.list();

     

    9. 子对象关联@CountRelt(uiFld="groupid",fld="departId")

    Equipment eq;

     

    解释器实现

     

     setCountRelt2(list_sub);   

     

    private void setCountRelt2(List<Map> list_sub) {

    // attilax 老哇的爪子  2_47_6   o9r 

    //List<String> CountReltFldsList=getCountReltFldsList();

    for (Map map : list_sub) {

    //for (String fldName : CountReltFldsList) {

    //Class rltCls = getFldClass(fldName);      equmnet :eq  

    //Field idFld = null;

    //try {

    //idFld = refx.getIdFld_EXO9o(rltCls);

    //} catch (cantFindMatchFieldException e) {

    ////  attilax 老哇的爪子 10_58_h   o9q   

    ////e.printStackTrace();

    //core.warn(e);

    //}

    Object idVal = map.get("equipmentId");  //eqid

    if(idVal!=null)

    {

    Object rltObj = getSession().get(Equipment.class,(IntegeridVal);

    map.put("eq", rltObj );

    }

    //}

    }

    }

     

     

     

     

     

    我要啦免费统计
  • 相关阅读:
    cogs 908 校园网
    植保___农药基础知识
    底层终端-.c文件之间的调用
    指针复习
    电子工程世界
    电机与维修
    航拍部分
    系统集成与维修
    关于大型架构数据库和web一步一步优化草案
    服务器安装git,如何以秘钥方式提交
  • 原文地址:https://www.cnblogs.com/attilax/p/5963868.html
Copyright © 2020-2023  润新知