返回结果排序
HqlHelper配置
方法 | 等价HQL片段 |
---|---|
orderBy (String fromClazzFieldName, OrderType orderType) | order by fromClazz.fromClazzFieldName orderType |
orderBy (String tableAlias, String fieldName, OrderType orderType) | order by tableAlias.fieldName orderType |
例子
@Autowired
private HqlHelperService helperService;
@Test
public void testHql() {
// 查询城市名称、序号,按照序号降序排列,读取3条记录
HqlHelper helper = HqlHelper.queryFrom(City.class);
helper.fetch("sortSeq", "name")
.orderBy("sortSeq", OrderType.desc)
.setFirstResult(0).setMaxResults(3);
Records cityList = helperService.getRecords(helper, false);
System.err.println("cityList=" + cityList);
}
结果:
select
city0_.sort_seq as col_0_0_,
city0_.name as col_1_0_,
city0_.id as col_2_0_
from
dodo_city city0_
order by
city0_.sort_seq desc limit ?
cityList=Records [rawData=[
{name=, sortSeq=344, id=111222333},
{name=省直辖县级行政单位, sortSeq=343, id=1160799107483881472},
{name=三亚市, sortSeq=342, id=1160799107169308672}]]
当前内容版权归 DodoFramework 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 DodoFramework .