在Grails GORM查询中使用连接 [英] The use of join in Grails GORM queries
问题描述
Grails不会改变您编写HQL的方式无论您使用Grails域类还是POJO,它都是一样的。如果您需要编写查询来导航对象图,那么您需要使用与使用HQL相同的语法,如 FROM parent p JOIN p.child c WHERE c.age = 10
。 Criteria查询以相同的方式工作,但您只需要使用闭包。
查看 documentation (第5.4.3节)以获取更多信息。
In Grails we define domain classes in such a way that clearly indicates the relationship between domain classes such as one to many or belongsTo (if any). Since Grails is based on DRY, does that mean we do not need to use the join keyword when performing complex HQL queries in Grails DomainClass.ExecuteQuery method?
Grails doesn't change the way you write your HQL it is the same whether your using Grails domain classes or POJO's. If you need to write queries that navigate the object graph then you need to use the same syntax as you would with HQL like FROM parent p JOIN p.child c WHERE c.age = 10
. Criteria queries work in the same way but you just get to use closures.
Take a look at the documentation (section 5.4.3) for more information.
这篇关于在Grails GORM查询中使用连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!