以下查询是由休眠生成的
Select sum(B.c_rejected_count) as y0_,B.c_date as y1_,B.c_node_site_id as y2_,
A.c_sccp_addr as y3_ from tb_sccp_addr A inner join tb_dm_sccp_rej_day B on
A.c_sccp_addr_id=B.c_sccp_addr_fk group by A.c_date, A.c_node_site_id,
B.c_sccp_addr, B.c_sccp_addr_id ;
我的 Beanclass 有以下数据:
private Date date;
private long rejectedCount;
private int nodeSiteId;
private String sccpAddress;
当我将选择查询的结果列表转换为我的 beanclass 时,我得到一个转换异常
java.lang.ClassCastException
请确定出了什么问题以及如何解决
我正在使用 Java 反射
//函数初始化选择查询
private void initializeSelectQuery()
{
log(Level.DEBUG, "Entering initializeSelectQuery");
Class classname = beanclass.getMappedClass();
crit = hibernateSession.createCriteria(classname);
if(group.getAggregate().equals("SUM"))
{
projectionList.add(Projections.sum(beanDefinition
.getPropertyForColumn(group.getColumnName())));
}
else
{
projectionList.add(Projections.groupProperty(beanDefinition
.getPropertyForColumn(group.getColumnName())));
}
crit.setProjection(projectionList);
crit.setMaxResults(10);
}
public List executeSelectQuery() {
log(Level.DEBUG, "Entering executeSelectQuery");
List datalist = null;
try {
tx = hibernateSession.beginTransaction();
if (crit != null) {
datalist = crit.list();
}
tx.commit();
} catch (MappingException e) {
e.printStackTrace();
System.out.println(e.getMessage());
} catch (HibernateException e) {
e.printStackTrace();
}
log(Level.DEBUG, "Exiting executeSelectQuery");
return datalist;
}