首页 技术 正文
技术 2022年11月6日
0 收藏 816 点赞 1,119 浏览 2018 个字

/**
* <p>Title: getbigestMinIntegral</p>
* <p>Description: 获取最大的MinIntegral(原则上即最高等级的MinIntegral)</p>
* @param integral
* @param storeNo
* @return
* @author hedongfei
* @date 2019年3月14日
*/
@Override
public UserLevelEntity getbigestMinIntegral(String storeNo) {
      StringBuffer hql = new StringBuffer(” select * FROM user_level WHERE storeNo=:storeNo ORDER BY minIntegral desc LIMIT 0,1 “);

Query q = this.getSession().createSQLQuery(hql.toString());
      q.setString(“storeNo”, storeNo);
      List<UserLevelEntity> result= q .list();
      if(result!=null && result.size()>0){
          return result.get(0);
       }
   return null;
}

以上写法报错,原因未知,猜测原因为:未正确转换对象。
q .list()转换值为:
[[“40285b81697b444e01697b4abba70004″,”0000000065123b530165125c69b20006″,”2019-03-14 16:21:29″,”0000000065123b530165125c69b20006″,”2019-03-14 16:21:29″,”0″,”Lv.4″,4,5000,10000,”5\r\n”,””,”1001″,”1001″]]

正确值应该为:

[[“40285b81697b444e01697b4abba70004″,”0000000065123b530165125c69b20006″,”2019-03-14 16:21:29″,”0000000065123b530165125c69b20006″,”2019-03-14 16:21:29″,”0″,”Lv.4″,4,5000,10000,”5\r\n”,””,”1001″,”1001″]]
[{“agencyNo”:”1001″,”createOper”:”0000000065123b530165125c69b20006″,”createTime”:”2019-03-14 16:19:56″,”delFlag”:”0″,”description”:”8\r\n”,”levelIcon”:””,”levelName”:”Lv.1″,”mapCondition”:{},”maxIntegral”:499,”minIntegral”:100,”position”:2,”sheetRow”:0,”sortFieldName”:”createTime”,”sortType”:”desc”,”storeNo”:”1001″,”updateOpeTime”:”2019-03-14 16:19:56″,”updateOper”:”0000000065123b530165125c69b20006″,”uuid”:”40285b81697b444e01697b4952890001″}]

改变写法如下:改为添加转换实体类.addEntity();

/**
* <p>Title: getbigestMinIntegral</p>
* <p>Description: 获取最大的MinIntegral(原则上即最高等级的MinIntegral)</p>
* @param integral
* @param storeNo
* @return
* @author hedongfei
* @date 2019年3月14日
*/
@Override
public UserLevelEntity getbigestMinIntegral(String storeNo) {
      StringBuffer hql = new StringBuffer(” select * FROM user_level WHERE storeNo='”+storeNo+”‘ ORDER BY minIntegral desc LIMIT 0,1 “);

List<UserLevelEntity> result= this.getSession().createSQLQuery(hql.toString()).addEntity(UserLevelEntity.class).list();
     if(result!=null && result.size()>0){
          return result.get(0);
      }
   return null;
}

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,983
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,500
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,344
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,127
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,761
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,838