hibernate多表查询
来源:互联网 发布:apache storm java应用 编辑:程序博客网 时间:2024/05/19 13:10
一:将需要查询的字段抽取出来,建议个新类,用构造函数将其初始化。
二:写SQL语句,查出你要查的结果,用List<Object>保存,再将其转成你所建的新类。
代码:
public List<AwardAndRecommend> getAllRecommends() {
StringBuffer hql = new StringBuffer();
List<AwardAndRecommend> aars = new ArrayList<AwardAndRecommend>();
hql.append("select a.rcmdName, h.hrsPrmPstTitle, h.locationId, h.openDt,a.rcmdDt, h.statusCode, h.apprBonus,h.hrsJobOpeningId,a.userId"
+ " from HRSJoRecommendVO a,HRSAwardRecruitVO h where a.openingId=h.hrsJobOpeningId");
log.debug("hql = " + hql.toString());
Session session = sessionFactory.getCurrentSession();
Query query = session.createQuery(hql.toString());
List<Object> voList = query.list();
for (int i = 0; i < voList.size(); i++) {
Object[] o = (Object[]) voList.get(i);
AwardAndRecommend aar = new AwardAndRecommend((String) o[0],
(String) o[1], (Long) o[2], (Date) o[3], (Date) o[4],
(String) o[5], (Double) o[6], (Long) o[7], (String) o[8]);
aars.add(aar);
}
return aars;
}
- hibernate多表查询
- hibernate多表查询
- Hibernate多表查询
- hibernate多表查询
- hibernate多表查询
- Hibernate 多表查询
- hibernate多表查询
- hibernate多表查询
- hibernate多表查询
- Hibernate多表查询
- hibernate 多表查询
- hibernate多表查询
- hibernate 多表查询
- hibernate多表查询
- hibernate 多表查询
- hibernate多表查询
- hibernate多表查询
- Hibernate多表查询
- lucene 索引文件简介
- 实际项目中的一个实例
- 说说内存对齐吧
- 分享一些php免费课程给大家
- jQuery对象到底是什么
- hibernate多表查询
- 5分钟了解Mockito
- NSObject详解
- HDU4960:Another OCD Patient
- jmeter 数据库测试
- 写块克隆--WblockCloneObjects
- Maven学习(一)之初识
- 在Hadoop2.2下安装配置Hive
- shell awk实现实时监控网卡流量脚本(常见应用二)