lovezwlhjj 2014-08-05 09:46 采纳率: 0%
浏览 914

hql拼接语句时的空格问题

下面两段代码是我拼接hql语句的两种:
1、if(hql.indexOf("where")==-1){
hql += " where archiveTime is not null and netType = '"+netType+"' ";
}else{
hql += " and archiveTime is not null and netType = '"+netType+"' ";
}

        if(companyName!=null&&!"".equals(companyName)){
            hql+="and Business_.lowerName.customer.name1 like '%"+companyName+"%'";
        }

下面是第二种:
2、 if(hql.indexOf("where")==-1){
hql += " where archiveTime is not null and netType = '"+netType+"'";
}else{
hql += " and archiveTime is not null and netType = '"+netType+"'";
}

        if(companyName!=null&&!"".equals(companyName)){
            hql+=" and Business_.lowerName.customer.name1 like '%"+companyName+"%'";
        }

乍一看两个是没有区别的,但是注意看会发现,第一个在netType后面加了空格,第二个是在and 之前加的空格。两种运行的第一种是正确的,第二种是错误的。网上找不到资料,忘各位大神帮忙分析下原因。

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器