hibernate中hql语句获取名次rank()问题
来源:互联网 发布:淘宝网包包 女包0-20元 编辑:程序博客网 时间:2024/04/29 04:21
public class RankFunction implements SQLFunction {public RankFunction() {}@Overridepublic Type getReturnType(Type arg0, Mapping arg1) throws QueryException {return Hibernate.INTEGER;}@Overridepublic boolean hasArguments() {return true;}@Overridepublic boolean hasParenthesesIfNoArguments() {return true;}@Overridepublic String render(List args, SessionFactoryImplementor factory) throws QueryException {if (args.size() != 1) {throw new IllegalArgumentException("RankFunction requires 1 argument!");}return "rank() over(order by " + args.get(0) + ") ";}}
<pre name="code" class="java">// 自定义言类,替换beans.xml默认方言
public class SQLServer2005Dialect extends SQLServerDialect {public SQLServer2005Dialect() {registerFunction("rank", new RankFunction());}}
我用的sqlserver2005
自定义hibernate方言即可,在hql中调用
select rank(column) from table
0 0
- hibernate中hql语句获取名次rank()问题
- Hibernate 中HQL语句
- Hibernate 中HQL语句
- Hibernate中HQL语句
- hibernate中HQL语句
- hibernate中hql语句
- Hibernate 中HQL语句
- Hibernate中HQL语句
- hibernate的hql语句问题
- hibernate中hql语句大全
- hibernate hql语句如何获取枚举类型
- hibernate 中HQL语句查询学习
- Hibernate中HQL使用SELECT语句
- Hibernate中HQL语句的使用
- Hibernate中HQL语句的使用
- Hibernate中使用HQL语句删除数据
- hibernate 中HQL语句查询学习
- Hibernate中常用的HQL语句总结
- 安卓点击软键盘的回车即提交数据并隐藏软键盘
- 一些软件设计原则
- javascript中区分鼠标单击和拖动事件
- 怎样花两年时间去面试一个人
- c#转为8位灰度图像和转为1位黑白图像
- hibernate中hql语句获取名次rank()问题
- 着手实验所碰到的Matlab问题
- 小型团队快速开发方法
- Map-Reduce数据分析之一(实例2通话清单分析)
- 单例模式之懒汉模式Meyers版本
- 程序设计:与随机数的判断
- 【.Net码农】huangxincheng一线码农系列--8天入门wpf
- /dev、/sys/dev 和/sys/devices 和udev的关系
- opencv VideoWriter保存视频失败原因