2 qq 36128558 qq_36128558 于 2017.09.04 18:21 提问

SSH框架查询问题求大神解释下谢谢!!
ssh

SSH框架
查询是的错误
hql语句改为sql语句数据库执行没错误

 public Page getUserListNew(SaaUser saaUser, int pageNo, int pageSize,
            String userCodeOperate) {
        StringBuffer hql = new StringBuffer();
        hql.append(" from SaaUser saaUser where 1=1 and saaUser.userCode <> '00000000'");
        if(!userCodeOperate.equals("00000000")){
            String comCodeSql=saaPowerService.addPower(userCodeOperate, IConstants.SAA, "", "saaUser.comCode", "", "", "");
            hql.append(" and saaUser.userCode<>'"+userCodeOperate+"'");
            hql.append(" and "+comCodeSql);
        }
        hql.append(" and saaUser.validStatus='1'");
        HqlRulesUtil hqlRulesUtil = new HqlRulesUtil();
        hqlRulesUtil.addLike("saaUser.userCode", saaUser.getUserCode());
        hqlRulesUtil.addLike("saaUser.comCode", saaUser.getComCode());
        hqlRulesUtil.addLike("saaUser.userName", saaUser.getUserName());
        logger.info("hql.toString()"+hql.toString());
        if (hqlRulesUtil.getHql().trim().length() != 0) {
            hql.append(" and ").append(hqlRulesUtil.getHql());
        }
        Page page = findByHql(hql.toString(), pageNo, pageSize, null);
        List<SaaUser> list = page.getResult();
        List<UserQueryCondition> resultLists = new ArrayList<UserQueryCondition>();
        for(SaaUser user:list){
            UserQueryCondition condition = new UserQueryCondition();
            try {
                BeanUtils.copyProperties(condition, user);
            } catch (IllegalAccessException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            PrpDcompany dcompany = super.get(PrpDcompany.class, user.getComCode());
            if(null == dcompany || dcompany.equals("")){
                condition.setComCName("");
            }else{
            condition.setComCName(dcompany.getComCName());
            }
            resultLists.add(condition);
        }
        Page retPage = new Page(0, page.getTotalCount(), pageSize, resultLists);
        return retPage;
    }

1个回答

Sweet__dream
Sweet__dream   2017.09.05 09:19

建议设置断点一步一步的调试,很快就会发现问题的出处

Csdn user default icon
上传中...
上传图片
插入图片