Details
-
Type:
Sub-task
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.0-RC1
-
Fix Version/s: 2.2-RC2
-
Component/s: Persistence
-
Labels:None
-
Environment:Lion,JDK 6
Description
the original url: http://grails.1312388.n4.nabble.com/DetachedCriteria-s-association-query-td3989063.html
I have some domains which association reference are more than 2,for example:
Class A { B b } Class B{ C c } Class C { String name }
When i use the detachedCriteria like this:
new DetachedCriteria(A).build {
b {
c {
eq('name','test')
}
}
}
There will throw such exception:
message: could not resolve property: c of: A
>> 639 | doCall in grails.gorm.DetachedCriteria$_list_closure2
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
867 doCall in grails.gorm.DetachedCriteria$_withPopulatedQuery_closure9 540 doCall . . . . . . . in org.grails.datastore.gorm.GormStaticApi$_withDatastoreSession_closure18 301 execute in org.grails.datastore.mapping.core.DatastoreUtils 34 execute . . . . . . in org.grails.datastore.gorm.AbstractDatastoreApi 539 withDatastoreSession in org.grails.datastore.gorm.GormStaticApi 850 withPopulatedQuery . in grails.gorm.DetachedCriteria
I'm getting this same error in 2.0.3. Here's a routine that looks to me like it should work, but I get the same exception described above. "could not resolve property 'user' of 'StatusUpdate'"
The 'user' property belongs to the UpdateStream object references by the association "streams"
def Collection<StatusUpdate> getUpdates(String streamName, DetachedCriteria crit, Map params = [:]) {
{ it.externalID }crit = crit.build {
streams {
and {
eq 'name', streamName
user {
inList 'externalID', this.socialAccounts.collect
}
}
}
}
crit.list(params)
}