我在休眠中使用本機查詢,它會返回我的id列表。我想將這個列表轉換爲整數列表。但它不起作用,給我看例外。休眠本機查詢返回整數列表不工作
public List<Integer> fethcSurvayIdOnCount(){
HibernateCallback action = new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
String hq = "select id from tb_abc where age='10'" ;
SQLQuery query = (SQLQuery) session
.createSQLQuery(hq)
.setResultTransformer(
Transformers
.aliasToBean(Integer.class));
return query.list();
}
};
return (List<Integer>) getHibernateTemplate()
.execute(action);
}
這裏是例外
org.springframework.orm.hibernate3.HibernateSystemException: Could not find setter for id on class java.lang.Integer; nested exception is org.hibernate.PropertyNotFoundException: Could not find setter for id on class java.lang.Integer
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:676)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:339)
什麼是ID這裏 – PSR 2013-03-22 14:17:46