Detached Criteria and @GrailsCompileStatic

37 views
Skip to first unread message

Nikola Ivanov

unread,
Mar 18, 2016, 11:13:21 AM3/18/16
to Grails Dev Discuss
Hi,

I'm trying to use @GrailsCompileStatic on a Service that uses DetachedCriteria in its code,
but the build throws compilation errors complaining that methods like gte(fieldName, value) are not defined.

example:
def criteria = new DetachedCriteria(ContractDetails).build {
gte('startTime', startTime)
}

/ContractDetailsService.groovy: 141: [Static type checking] - Cannot find matching method ContractDetailsService#eq(java.lang.String, ContractDetails). Please check if the declared type is right and if the method exists.

 @ line 141, column 17.

                   gte('startTime', startTime)


Same code compiles when createCriteria instead of DetachedCriteria is used.


Wondering if this is some expected behaviour?

Jeff Scott Brown

unread,
Mar 18, 2016, 12:50:06 PM3/18/16
to grails-de...@googlegroups.com
Does this compile?


ContractDetails.where {
// startTime is the name of the property in
// ContractDetails and variableStartTime
// is the name of some variable accessible
// in this scope
startTime >= variableStartTime
}




JSB


Jeff Scott Brown
Principal Software Engineer
Grails Development Team
Object Computing Inc.
http://www.ociweb.com/

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

Nikola Ivanov

unread,
Mar 22, 2016, 11:21:04 AM3/22/16
to Grails Dev Discuss
Yes that one compiles just fine.

Thanks for the tip.

BR,
Nikola
Reply all
Reply to author
Forward
0 new messages