hiernate 中联合查询,得到的list是一个对象数组,这样需要进行适当处理来取值。
// 查找记录 的方法: public static List list(String query)
hbSession = DaoUtil.openSession();
Query q = hbSession.createQuery(query);
iter = q.list();
hbSession.flush();
查询sql语句:
List list = DaoUtil.list(" select obj.id,obj2.returnTime,obj2.freezeTime from "
+ " com.etraveltek.abt.prj.entity.ProjectEntity as obj,"
+ "com.etraveltek.abt.prj.entity.ListStrategyEntity as obj2 "
+ " where obj.id = obj2.projectId ");
for (int i = 0; i < list.size(); i++) {
Object[] objs = (Object[]) list.get(i);
if (objs != null) {
int returnLimit = 0;
int freezeTime = 0 ;
try {
returnLimit = ((Integer) objs[1]).intValue();
} catch (Exception e) {
}
try {
freezeTime = ((Integer) objs[2]).intValue();
} catch (Exception e) {
}
}