String hql = "select count(*) from Friend where userID = ?";
int totalCount = this.countByCondition(hql, userID);

在查询的时候出现了java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-base错误,后来在网上查询了一下。,得知JPA的问号索引是从1开始的,而HibernateTemplate是从0开始的。