GORM/grails深度不同关联查询条件
我有以下查询中指定的每个表的域对象。我在创建代表以下 SQL 查询的 withCriteria 闭包时遇到问题。有什么想法吗? 谢谢! Steve
SQL 查询:
select A_NAME from A
where A_XID =
(select A_XID from B
where B_XID =
(select distinct B_XID from C
where D_XID = '${d.dXid}')
域对象:
class A {
String aName
BigDecimal aXid <-- unique identifier
}
class B {
A a
BigDecimal bXid <-- unique identifier
}
class C {
D d
B b
}
I have domain objects for each table specified in the below query. I'm having trouble creating the withCriteria closure representing the below SQL query. Any thoughts?
Thanks!
Steve
SQL Query:
select A_NAME from A
where A_XID =
(select A_XID from B
where B_XID =
(select distinct B_XID from C
where D_XID = '${d.dXid}')
Domain Objects:
class A {
String aName
BigDecimal aXid <-- unique identifier
}
class B {
A a
BigDecimal bXid <-- unique identifier
}
class C {
D d
B b
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道如何使用条件查询来做到这一点,但在 HQL 中它会
,但你遗漏了很多信息,所以这是基于你有这些域类的假设(你省略了 D类和映射):
I'm not sure how to do this with a criteria query, but in HQL it'd be
but you've left out a lot of information, so this is based on the assumption that you have these domain classes (you omitted the D class and mappings):