//hibernate查询部分字段转换成实体bean

    /**
     * 查询线路信息
     */
    @Override
    public List<Line> getSimpleLineListByTj(Map<String,Object> paramMap){

        Criteria cr=this.getSession().createCriteria(Line.class,"Line");
//        cr.setFetchMode("chuTuanInfo", FetchMode.JOIN);
//        Criteria teamche=cr.createAlias("chuTuanInfo","chuTuanInfo", JoinType.LEFT_OUTER_JOIN);
//        Criteria teamPlanCR=cr.createAlias("teamplan","teamplan", JoinType.LEFT_OUTER_JOIN);
        ProjectionList pList=Projections.projectionList();
//        pList.add(Projections.property("id"));
//        pList.add(Projections.property("linename"));
        pList.add(Projections.alias(Projections.property("id"), "id"));//使用别名才能aliasToBean到Line
        pList.add(Projections.alias(Projections.property("linename"), "linename"));
//        pList.add(Projections.property("teamplan.renshu"));
        cr.setProjection(pList);

//        FaTuanState.getMap();
//        List<String> propertyNameList = new ArrayList();
//        propertyNameList.add("id");
//        propertyNameList.add("linename");
//        List list =  getListWithPartProperty(cr, propertyNameList);

//        Map<String,Object> paramMap = new HashMap<String,Object>();
//        paramMap.put(key, value);

        cr.add(Restrictions.ne("state", FaTuanState.TINGFA));//《》停发和暂停的
        cr.add(Restrictions.ne("state", FaTuanState.ZANTING));

        if(paramMap.get("areaid")!=null && !StringUtils.isBlank(paramMap.get("areaid").toString())){
            cr.add(Restrictions.eq("jingqu.id", Integer.parseInt(paramMap.get("areaid").toString())));
        }

        cr.addOrder(Order.asc("linename"));
        cr.setResultTransformer(Transformers.aliasToBean(Line.class));

        return cr.list();
    }

hibernate查询部分字段转换成实体bean的更多相关文章

  1. Java—JSON串转换成实体Bean对象模板

    介绍 模板需求说明   开发中经常遇到前端传递过来的JSON串的转换,后端需要解析成对象,有解析成List的,也有解析成Map的. 依赖 <dependency> <groupId& ...

  2. hibernate sql查询后对象转换成实体类

    在多表查询的时候使用hibernate的sql查询的时候,一般返回的是object[]数组,或者可以使用  session.createSQLQuery(sql).setResultTransform ...

  3. sql hibernate查询转换成实体或对应的VO Transformers

    sql查询转换成实体或对应的VO Transformers //addScalar("id") 默认查询出来的id是全部大写的(sql起别名也无效,所以使用.addScalar(& ...

  4. DataTable转换成实体

    public static class DataTableToEntity { /// <summary> /// 将DataTable数据源转换成实体类 /// </summary ...

  5. C# 将DataTable数据源转换成实体类

    using System; using System.Collections.Generic; using System.Data; using System.Reflection; /// < ...

  6. 字符串js编码转换成实体html编码的方法(防范XSS攻击)

    js代码在html页面中转换成实体html编码的方法一: <!DOCTYPE html><html> <head>    <title>js代码转换成实 ...

  7. C# DataTable转换成实体列表 与 实体列表转换成DataTable

    /// <summary> /// DataTable转换成实体列表 /// </summary> /// <typeparam name="T"&g ...

  8. Oracle中将Clob字段转换成字符串

    1. 利用dbms_lob.substr()方法可将对应字段转换成字符串如下 select dbms_lob.substr(content) from NEWS 该方法有个缺点,当content字段长 ...

  9. How to cast List<Object> to List<MyClass> Object集合转换成实体集合

    List<Object> list = getList(); return (List<Customer>) list; Compiler says: cannot cast  ...

随机推荐

  1. linux下vim编辑器使用

    VIM - Vi IMproved: vim是vi编辑器的升级版,是linux下标准的编辑器,具有程序编写能力,可以根据字体颜色辨别语法的正确性,方便程序的设计. 使用: # vim [OPTION] ...

  2. Telegram学习解析系列(二):这我怎么给后台传输数据?

    写在前面: 在iOS开发的过程中,有很多时候我们都在和数据打交道,最基本的就是数据的下载和上传了,估计很多很多的小伙伴都在用AFNetworking与后台数据打交道,可有没有想过,哪天AFNetwor ...

  3. Cygwin Unable to get setup from *

    Cygwin Unable to get setup from * 错误 解决方案 是因为用自定义镜像站点,比如 http://mirrors.xdlinux.info/cygwin/x86_64/ ...

  4. Java_中建立0-10M的消息(字符串)

    直接用StringBuilder,它的append方法方便快速构建字符串. StringBuilder sb1=new StringBuilder(); for(int i=0;i<1024*1 ...

  5. 常用的CI笔记

    1. thinkphp 封装好的$this->success(),就直接实现成功跳转,$this->error(),错误跳转.CI有show_error(),但是却不能直接实现跳转,所以需 ...

  6. linux系统管理--查看进程

    关于进程的查看,大家都不会陌生 ,主要是ps和pstree命令. ps  aux    查看系统中所有进程,使用BSD操作系统格式.(注意:不是ps -aux) 执行结果 USER :该进程是由哪个用 ...

  7. Hibernate中遇到的一个Exception

    做项目的时候遇到一个很头疼的报错:Illegal attempt to associate a collection with two opensessions 出错原因:  一个Object Ver ...

  8. 使用nodejs爬前程无忧前端技能排行(半半成品)

    最近准备换工作,需要更新一下技能树.为做到有的放矢,想对招聘方的要求做个统计.正好之前了解过nodejs,所以做了个爬虫搜索数据. 具体步骤: 1.  先用fiddler分析请求需要的header和b ...

  9. OpenGL: Rotation vector sensor of Android and Device motion of iOS

    为了实现一个全景图片展示的功能,需要借助手机的姿态传感器,实现一个这样的功能:当手机旋转时,视角也跟着旋转(读者若理解不能,可以参考下现在流行的 VR 应用,使用陀螺仪模式时的效果,亦可称作" ...

  10. HttpGet和HttpPost

    package net.blogjava.mobile; import java.net.HttpURLConnection; import java.util.ArrayList; import j ...