【发布时间】:2014-07-27 22:46:51
【问题描述】:
我有以下域类:
class AccountRecord {
List owners // owner of this account
}
和
class IndividualRecord {
String uniqueId
String secondaryId
List accounts // accounts owned by this individual
}
AccountRecord 类中的 owners List 通过存储包含每个所有者的 uniqueId 和 secondaryId 对的映射来存储该帐户的所有所有者。因此,所有者列表可能如下所示:
[
[uniqueId: 1, secondaryId 2] // owner 1
[uniqueId: 2, secondaryId 3] // owner 2
]
假设我想使用 GORM 查找所有 AccountRecord 的所有者列表包含一个地图,该地图包含给定的 IndividualRecord 的 uniqueId 和 secondaryId。基本上,给定一个个人,找到该个人拥有的所有帐户。目前我正在这样做,但它不起作用(由于某种原因,它还返回不属于个人所有的帐户):
def accountsOwnedByUser = AccountRecord.where {[uniqueId: someOwner.uniqueId, secondaryId: someOwner.secondaryId] in owners}.list()
有什么建议吗?
【问题讨论】: