使用内部联接从mysql查询Grails createCriteria

时间:2014-06-11 15:32:16

标签: grails

我有这个mysql查询

SELECT cr1.project_id 
FROM contribution_request as cr1
INNER JOIN contribution_request as cr2 ON cr1.project_id = cr2.project_id 
WHERE cr1.instrument_id = 5 AND cr2.instrument_id = 6

我需要通过grails createCriteria function

执行它

我试过这个,但它不起作用,我找不到怎么做。

 def pc = ContributionRequest.createCriteria();
    def Object = pc.list {

        projections {
            property("project.id")
        }

        and {
            eq "instrument.id", 5L
            eq "instrument.id", 6L
        }
    }

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

当您使用- - "1234"时,应使用projections代替get。您的代码如下所示:

list