如下
使用
SELECT COUNT(*)
然后获取最大值
Integer.parseInt(query.list().get().toString());
比如
StringBuffer hql1;
hql1 = new StringBuffer(" SELECT COUNT(*) FROM ArticleModel WHERE tags like '%")
.append(id)
.append("%'");
Query query = session.createQuery(hql1.toString());//
return Integer.parseInt(query.list().get().toString());
即可