关于数据表的查询和取值
ssh框架,model里有Result和Count两个不同的类
public class Result {
private int day;
private int month;
public int getDay() {
return day;
}
public void setDay(int day) {
this.day = day;
}
public int getMonth() {
return month;
}
public void setMonth(int month) {
this.month = month;
}
}
public class Count {
private int id;
private String indate;
public String getIndate() {
return indate;
}
public void setIndate(String indate) {
this.indate = indate;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
Dao的实现类中有如下代码:
...
List<Result> list=(List<Result>)hibernateTemplate.find("select day(indate),month(indate) from com.chart.model.Count group by day(indate)");
System.out.println(list.get(0).getDay());<==========打印不出来
...
为什么打印不出来呢?
list里面有值,是不是因为不能转换成Result类型,改怎么改呢?