1. java.lang.Integer cannot be cast to java.lang.Long
当使用hibernate的查询函数count(),sum()等的值时(注意:一定是只返回唯一值的并且为数字格式是才可以 )可已调用query的uniqueResult();方法 此方法返回Object对象,只需要把它转为Number类型,然后调用.intValue()即可。
例如:Integer count=((Number)(session.createQuery(hql)).uniqueResult()).intValue();
2. java.util.Date cannot be cast to java.sql.Timestamp
ps.setDate(new java.sql.Date(b_date.getTime()));(这是插入数据库是的Date)! 其中(new java.sql.Date(b_date.getTime()));是把java类型的Date转换成sql类型的Date
3.org.springframework.orm.hibernate3.HibernateQueryException: could not resolve property: AId of: com.ibeifeng.po.Critique [select count(*) from com.ibeifeng.po.Critique cri where cri.AId = ?]; nested exception is org.hibernate.QueryException: could not resolve property: AId of: com.ibeifeng.po.Critique [select count(*) from com.ibeifeng.po.Critique cri where cri.AId = ?]