我有我的 pojo 课程
掌握:
public class Master extends RecordSet{
private String empcode;
private String empname;
private String dept;
public String getEmpcode() {
return empcode;
}
public void setEmpcode(String empcode) {
this.empcode = empcode;
}
public String getEmpname() {
return empname;
}
public void setEmpname(String empname) {
this.empname = empname;
}
public String getDept() {
return dept;
}
public void setDept(String dept) {
this.dept = dept;
}
日期范围:
public class DateRange extends RecordSet {
private String ddate;
public String getDdate() {
return ddate;
}
public void setDdate(String ddate) {
this.ddate = ddate;
}
}
记录集:
public class RecordSet {
private DateRange daterange;
private Master master;
public DateRange getDaterange() {
return daterange;
}
public void setDaterange(DateRange daterange) {
this.daterange = daterange;
}
public Master getMaster() {
return master;
}
public void setMaster(Master master) {
this.master = master;
}
}
我有我的休眠代码:
SQLQuery query = session
.createSQLQuery("CALL AbsentReportproc(:_fromdate,:_todate)");
query.addEntity(Master.class);
query.addEntity(DateRange.class);
query.setParameter("_fromdate", "2012-12-03");
query.setParameter("_todate", "2012-12-04");
List<Object[]> obj = query.list();
System.out.println(obj);
List<RecordSet> recordset = new ArrayList<RecordSet>();
Iterator it = obj.iterator();
while (it.hasNext()) {
Object[] object = (Object[]) it.next();
for (int i = 0; i < object.length; i++) {
RecordSet set = (RecordSet) object[i];
recordset.add(set);
System.out.println(set);
//Here I am able to print
//edu.model.Master@15093f1
//edu.model.DateRange@e6f7d2
//edu.model.Master@19836ed
//edu.model.DateRange@3e0ebb
//edu.model.Master@39443f
//edu.model.DateRange@e6f7d2 etc................
}
}
}
我的要求是使用 JSTL 标签在 jsp 中显示两者(Master 和 DateRange)的结果
任何人都可以如何获得最终的 List 对象来迭代和显示两个 pojo 的结果
我想显示 Master Pojo 的 EmployeeName、Code、Dept 和 DateRange Pojo 的 ddate?
当我迭代 RecordSet 列表时,我无法打印值(获取空指针异常)?