我有模型课:
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;
}
}
public class DateRange {
private Date ddate;
public Date getDdate() {
return ddate;
}
public void setDdate(Date ddate) {
this.ddate = ddate;
}
}
public class Master {
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;
}
}
我有这样的声明
List<RecordSet> list = (List<RecordSet>) query.list();
当上面的语句得到执行时,我得到了列表对象并且每个对象都包含两个项目(Master,DateRange)?
任何人都可以如何获得这两个模型类对象
我试过但面临类转换异常:
List<RecordSet> list = (List<RecordSet>) query.list();
for(int i=0;i<list.size(); i++){
Object set=list.get(i);
Master masetr=(Master)set;
System.out.println(masetr);
}
谢谢