Hibernate-hibernate 中 Long 与 int 的转换
hibernate 中使用聚合函数 count 查询记录数时,返回值类型为 Long ,若强行转换则会出现 java.lang.ClassCastException 异常,
正确写法应使用 Number 类型作为过渡则不会出错。
错误写法:
@Override
public int findCountByCid(Integer cid) {
String hql = "SEL
原创
2016-12-11 21:44:34 ·
2034 阅读 ·
0 评论