---
title: "Hibernate使用count(*)取得表中记录总数(跨Hibernate3.x版本问题)（转）"
author: "jiangchuhan"
date: "2010-07-02T15:33:00Z"
tags: []
slug: "hibernate-count-hibernate3-x"
draft: false
lastmod: "2014-02-16T13:23:36Z"
id: 2017708
url: "https://jiangchuhan.iteye.com/blog/2017708"
---

从Hibernate 3.0.x/3.1.x升级到最新的3.2版之后，3.2版的很多sql函数如count(), sum()的唯一返回值已经从Integer变为Long，如果不升级代码，会得到一个ClassCastException。