private Map<String, Object> createWblHqlContext(boolean needGroup, String startDate, String endDate) {
        Map<String, Object> context = new HashMap<String, Object>();
        // 构建hql
        StringBuilder hql = new StringBuilder();
        hql.append(this.createVaInfoWblDaySelectPart(startDate, endDate)).append(" ");

hql.append("from WfjWbl t where 1=1 ");
        List<Object> params = new ArrayList<Object>();
        if (startDate.length() > 0) {
            hql.append(" and t.settlementDate >= ?");
            params.add(startDate);
        }
        if (endDate.length() > 0) {
            hql.append(" and t.settlementDate <= ?");
            params.add(endDate);
        }
        if (needGroup)
            hql.append(" ").append(this.createVaInfoWblDayGroupByPart());
        context.put("hql", hql.toString());
        context.put("params", params);
        return context;
    }

// 构造select字段
    private String createVaInfoWblDaySelectPart(String startDate,String endDate) {
        StringBuilder sb = new StringBuilder();
        sb.append("select t.settlementDate,");// 清算日期
        sb.append("sum(t.amount)/100 ,"); // 清算交易金额
        sb.append("sum(t.amount)/100 ,"); // 交易笔数
        sb.append("sum(t.shopfee)/100 ,"); // 商户手续费
        sb.append("((sum(t.sdsy)/100-sum(t.advancefee)/100)) ,"); // 王府井入账金额
        sb.append("sum(t.sdsy)/100, "); // 收单收入
        sb.append("sum(t.wangsy)/100,"); // 王府井收入
        sb.append("sum(t.cjfsy)/100, "); // 插件方收入
        sb.append("sum(t.wangsh)/100, "); // 王府井损失
        sb.append("sum(t.cjfsh)/100 "); // 插件方损失
        sb.append("( ").append(this.createNoCardPayQueryThirdsySelectByPart())
        .append(this.createNoCardPayQueryThirdsyFromByPart(startDate, endDate))
        .append(" and t.mernum = '898110248990216'").append(this.createVaInfoWblDayGroupByPart()).append(") ");//代垫手续费(国美)

return sb.toString();
    }

// 构造group by字段
    private String createVaInfoWblDayGroupByPart() {
        StringBuilder sb = new StringBuilder();
        sb.append("group by t.settlementDate ");
        return sb.toString();
    }
    
    //构造sql查询代垫手续费,
    private String createNoCardPayQueryThirdsySelectByPart() {
        StringBuilder sb = new StringBuilder();
        sb.append("select sum(t.thirdsy)/100 ");
        return sb.toString();
    }

//构造sql查询代垫手续费的from部分
    private String createNoCardPayQueryThirdsyFromByPart(String startDate, String endDate) {
        StringBuilder sb = new StringBuilder();
        sb.append("from WfjWbl t where 1=1 ");
        List<Object> params = new ArrayList<Object>();
        if (startDate.length() > 0) {
            sb.append(" and t.settlementDate >= ?");
            params.add(startDate);
        }
        if (endDate.length() > 0) {
            sb.append(" and t.settlementDate <= ?");
            params.add(endDate);
        }
        return sb.toString();
    }

当添加红色部分内容时,页面就报org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: ( near line 1, column 215 [select t.settlementDate,sum(t.amount)/100 ,sum(t.amount)/100 ,sum(t.shopfee)/100 ,((sum(t.sdsy)/100-sum(t.advancefee)/100)) ,sum(t.sdsy)/100, sum(t.wangsy)/100,sum(t.cjfsy)/100, sum(t.wangsh)/100, sum(t.cjfsh)/100 ( select sum(t.thirdsy)/100 from cn.net.wangfujing.model.WfjWbl t where 1=1 and t.settlementDate >= ? and t.settlementDate <= ? and t.mernum = '898110248990216'group by t.settlementDate ) from cn.net.wangfujing.model.WfjWbl t where 1=1 and t.settlementDate >= ? and t.settlementDate <= ? group by t.settlementDate

求助!!!

关于hibernate子查询参数的问题的更多相关文章

  1. hibernate子查询

    对于支持子查询的数据库,Hibernate支持在查询中使用子查询.一个子查询必须被圆括号包围起来(经常是SQL聚集函数的圆括号). 甚至相互关联的子查询(引用到外部查询中的别名的子查询)也是允许的. ...

  2. hibernate HQL查询参数设置

    Hibernate中对动态查询参数绑定提供了丰富的支持,那么什么是查询参数动态绑定呢?其实如果我们熟悉传统JDBC编程的话,我们就不难理解查询参数动态绑定,如下代码传统JDBC的参数绑定: Prepa ...

  3. 利用Hibernate子查询(in) 得到部分字段(实体类的构造函数)

    感人= = 终于弄好了 String hql="select new Shop(s.strid,s.shopname,s.tradearea,s.discountinfo,s.beginti ...

  4. Oracle子查询和多表查询

    多表查询需要用到表的连接 连接可以分为:(自行百度) 交叉连接(数字逻辑的笛卡尔积,不做解释) 等值连接 例如:select * from t_a, t_b where t_a.xx = t_b.xx ...

  5. Hibernate 函数 ,子查询 和原生SQL查询

    一. 函数 聚合函数:count(),avg(),sum(),min(),max() 例:(1)查询Dept表中的所有的记录条数. String hql=" select count(*) ...

  6. Hibernate 分组查询 子查询 原生SQL

    分组查询: 使用group by关键字对数据分组,使用having关键字对分组数据设定约束条件,从而完成对数据分组和统计 1.1 聚合函数:常被用来实现数据统计功能 ① count() 统计记录条数 ...

  7. Hibernate HQL查询的参数绑定

    参数绑定: Hibernate中对动态查询参数绑定提供了丰富的支持,那么什么是查询参数动态绑定呢?其实如果我们熟悉传统JDBC编程的话,我们就不难理解查询参数动态绑定,如下代码传统JDBC的参数绑定: ...

  8. Hibernate HQL中的子查询

    子查询是SQL语句中非常重要的功能特性,它可以在SQL语句中利用另外一条SQL语句的查询结果,在Hibernate中HQL查询同样对子查询功能提供了支持.   如下面代码所示: List list=s ...

  9. hibernate的子查询

    hibernate原话 HQL supports subqueries in the where clause. We can't think of many good uses for subque ...

随机推荐

  1. 《Orange'S:一个操作系统的实现》笔记(一)

    感觉自己对于操作系统始终没有一个清楚的概念,尤其最近困扰于实模式.保护模式以及寻址方式等一些概念.转而一想,所有的程序,最终都是操作的计算机资源,需要和操作系统打交道,所以操作系统有必要深入了解一下. ...

  2. safari的调试工具

    safari的调试工具默认是没有打开的设置——>偏好设置——>高级———>在菜单栏中显示开发菜单

  3. Apache配置支持include

    Apache配置支持include 什么是SSI? SSI是英文Server Side Includes的缩写,翻译成中文就是服务器端包含的意思.从技术角度上说,SSI就是HTML文件中,可以通过注释 ...

  4. android 背景透明度渐变动画

    button.setVisibility(View.VISIBLE); // 背景透明度渐变动画 ObjectAnimator alpha = ObjectAnimator.ofFloat(butto ...

  5. 动态子类化CComboBox以得到子控件EDIT及LISTBOX

    动态子类化CComboBox以得到子控件EDIT及LISTBOX Joise.LI写于2004-4-6 ComboBox是比较常用的一个控件,有三种样式:CBS_SIMPLE(简单),CBS_DROP ...

  6. 《windows程序设计》学习_3.3:利用xp扫雷资源

    #include<windows.h> #include "resource.h" LRESULT CALLBACK WndProc (HWND, UINT, WPAR ...

  7. hdu 2421 Deciphering Password(约数个数问题)

    http://acm.hdu.edu.cn/showproblem.php?pid=2421 A^B 能够写成 p1^e1 * p2^e2 * .....*pk^ek.(A.B <= 10000 ...

  8. Objective-C中math.h数学计算公式介绍

    1. 三角函数  double sin (double); 正弦  double cos (double);余弦  double tan (double);正切 2 .反三角函数   double a ...

  9. SQL Server索引进阶:第十级,索引内部结构

    原文地址: Stairway to SQL Server Indexes: Level 10,Index Internal Structure 本文是SQL Server索引进阶系列(Stairway ...

  10. 关于js封装框架类库之DOM操作模块(一)

    在前端开发的过程中,javascript极为重要的一个功能就是对DOM对象的操作,而对其封装就是为了更好地进行DOM操作,提高浏览器的支持效率 现在给出一个案例:页面创建三个div,然后给其添加样式 ...