我在从休眠中的查询中获取信息时遇到问题。在我的班级dao中,有这样的功能。
@SuppressWarnings("unchecked")
public List<String> getOcurrencesPerMonth(){
List<String> dataOcurrences = (List<String>) getHibernateTemplate().execute (new HibernateCallback() {
public Object doInHibernate(Session session) {
Query query = session.createQuery("select concat(year(ror.created),'/',month(ror.created)), dt.name, count(distinct ror.id) from RawOccurrenceRecord ror, DataProvider dt" +
" where ror.dataProviderId = dt.id" +
" group by month(ror.created),ror.dataProviderId");
return query.list();
}
});
ArrayList<String> dataO = new ArrayList<String>();
Iterator<String> iterator = dataOcurrences.iterator();
while (iterator.hasNext()) {
dataO.add(iterator.next());
}
return dataO;
}
我将列表传递给视图,并在 jsp 中使用 ac:forEach 来查看结果,但我只有 Ljava.lang.Object;@1659f66 这样的结果
我在 MySQL 中的查询是
SELECT CONCAT(YEAR(raw_occurrence_record.created),'/',MONTH(raw_occurrence_record.created)), data_provider.name, COUNT(DISTINCT raw_occurrence_record.id) FROM raw_occurrence_record, data_provider WHERE raw_occurrence_record.data_provider_id = data_provider.id GROUP BY month(raw_occurrence_record.created), raw_occurrence_record.data_provider_id;
结果就像
2012/12 | POL | 15
2013/1 | JKL | 45
2013/1 | GTK | 30
¿如何在我的视图中获取查询中每一列的数据?