hql max基本语法如下:
String hql = "select max(p.id) from Player p";
Integer maxId = (Integer) playerDao.getSession().createQuery(hql).uniqueResult();
将某一字段转换为数字型再进行比较处理语法如下:
String hql = "select max(CAST(p.globalId as integer)) from Player p";
Integer maxId = (Integer) playerDao.getSession().createQuery(hql).uniqueResult();
获取某一字符字段除了第一位数转换后比较处理如下:
String hql = "select max(CAST(SUBSTRING(p.globalId, 2) as integer)) from Player p";
Integer maxId = (Integer) playerDao.getSession().createQuery(hql).uniqueResult();
本文详细介绍了HQL查询的基本语法,包括如何将特定字段转换为数字类型进行比较处理,以及获取字符字段中除首字母外的数字部分进行比较的方法。
1208

被折叠的 条评论
为什么被折叠?



