简体   繁体   English

比较来自同一域的两个对象createCriteria Grails

[英]compare two objects from same domain createCriteria Grails

Hi I have the following HQL query which I am running using executeQuery(): 嗨,我有以下正在使用executeQuery()运行的HQL查询:

def q = Domain.executeQuery("Select d0 from Domain d0 where d0.id = (select min(d1.id) from Domain d1 where d1.code = d0.code and d1.service = d0.service and d1.site = d0.site)");

I am trying to convert this HQL query so that the results are returned using createCriteria() instead of executeQuery() because I want to pass in pagination parameters. 我正在尝试转换此HQL查询,以便使用createCriteria()而不是executeQuery()返回结果,因为我想传递分页参数。 How would I go about doing this? 我将如何去做呢?

You can pass pagination parameters inside execute query also. 您也可以在execute查询中传递分页参数。 Just pass the pagination map inside after your query string and query params (if any): 只需在查询字符串和查询参数(如果有)之后传递分页图即可:
q = Domain.executeQuery("query", queryParams, paginationParams);
Please note, queryParams are optional 请注意, queryParams是可选的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM