使用HibernateTemplate,当返回的字段跟model不一致时的处理情况
来源:互联网 发布:网络歌手紫菱个人资料 编辑:程序博客网 时间:2024/05/21 04:21
public List<OnlineCustomerInforDTO> getOnlineMembersByTime(String beginTime, String endTime) {
final String hql = "select coi.email, count(coi.id) as onlineTimes from CustomerOnlineInfor coi where coi.beginDate between '"
+ beginTime + "' and '" + endTime + "' group by coi.email ";
List<OnlineCustomerInforDTO> onlineDTOList = null;
onlineDTOList = (List<OnlineCustomerInforDTO>) hibernateTemplate.execute(new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException, SQLException {
List<OnlineCustomerInforDTO> onlineDTOListtemp = new ArrayList<OnlineCustomerInforDTO>();
Query query = session.createQuery(hql); //由session执行hql语句,返回Query类型对象
//for 循环获取query的值并存入OnlineCustomerInforDTO对象中,然后将OnlineCustomerInforDTO对象add到list中
// 然后返回 list
for(Object o : query.list()) {
Object[] array = (Object[])o;
OnlineCustomerInforDTO onlineDTO = new OnlineCustomerInforDTO();
onlineDTO.setEmail(array[0].toString());
onlineDTO.setOnlineTimes(Long.parseLong(array[1].toString()));
onlineDTOListtemp.add(onlineDTO);
}
return onlineDTOListtemp;
}
});
return onlineDTOList;
}
- 使用HibernateTemplate,当返回的字段跟model不一致时的处理情况
- Mybatis高级映射之-数据库字段跟实体类名称不一致时的处理
- 当使用BCMenu 时,发现菜单不显示不一致时的处理
- MyBatis-处理字段名与实体类名不一致的情况 -04
- django model 返回指定的字段
- Mybatis 当实体属性与数据库字段不一致时的解决方案
- df和du显示的磁盘空间使用情况不一致的原因及处理
- df和du显示的磁盘空间使用情况不一致的原因及处理
- df和du显示的磁盘空间使用情况不一致的原因及处理
- df和du显示的磁盘空间使用情况不一致的原因及处理
- df和du显示的磁盘空间使用情况不一致的原因及处理
- df和du显示的磁盘空间使用情况不一致的原因及处理
- 怎样用自己的数据集对caffe训练好的model进行fineture(当类别数量不一致时)
- 使用hibernateTemplate模板执行只更新一个字段的操作
- oracle+mybatis 使用动态Sql当插入字段不确定的情况下实现批量insert
- oracle+mybatis 使用动态Sql当插入字段不确定的情况下实现批量insert
- 第四讲 属性名和字段名不一致的处理
- 当遇到处理复杂业务逻辑的情况,使用了hibernate,你是怎么处理的?
- jQuery基础教程之强大的选择器(过滤选择器-属性过滤选择器)
- Apache Commons fileUpload实现文件上传
- Java动态显示文件上传进度的简单实现
- OpenSSL库的编译与安装
- android wifi ap 自动开启
- 使用HibernateTemplate,当返回的字段跟model不一致时的处理情况
- 如何强制ffmpeg编码时输出一个关键帧
- platform设备驱动详解
- 关于ffmpeg中的VBR控制的讨论(编码时参数设置)
- 实习第五天——老大不在,自学成才。今日的十八个收获
- 安装gcc时的依赖包
- Android开发环境搭建
- Android开发--创建Activity 要点、注册
- Android开发 --- 多个Activity,及之间数据传递 Intent