我正在使用GORM查找程序,但我收到运行时错误,我认为这是因为我的语法不正确。以下是我遇到问题的代码行:
def accountsOwnedByUser = AccountRecord.findAllWhere(owners.contains(indivRecord.uniqueId))
其中owner是AccountRecord类的List属性。我想查找给定帐户的所有所有者,并且我是通过搜索帐户所有权列表中显示唯一ID的个人来完成的。但目前我收到了这个错误:
No such property: owners for class: com.twc.fatcaone.FileImportService. Stacktrace follows:
Message: No such property: owners for class: com.twc.fatcaone.FileImportService
Line | Method
->> 968 | doCall in com.twc.fatcaone.FileImportService$_$tt__deleteIndividualRecord_closure18
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 967 | $tt__deleteIndividualRecord in com.twc.fatcaone.FileImportService$$EOkgHOSW
| 168 | doCall . . . . . . . . . . . . in com.twc.fatcaone.FileImportService$_$tt__excelIndividualFileUpload_closure16$$EOkgHOSW
| 162 | $tt__excelIndividualFileUpload in com.twc.fatcaone.FileImportService$$EOkgHOSW
| 147 | upload . . . . . . . . . . . . in com.twc.fatcaone.CustomerController
| 198 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter . . . . . . . . . . . in grails.plugin.cache.web.filter.AbstractFilter
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 744 | run in java.lang.Thread
我需要类似it.owners
或其等价物的东西,可用作GORM动态查找器的参数。有没有等价的?
答案 0 :(得分:1)
你在找这样的东西吗?...
def idToSearchFor = indivRecord.uniqueId
AccountRecord.where {
idToSearchFor in owners
}.list()
如果没有看到你的模型,我无法确定,但这样的事情可能有所帮助。