Detached Criteria and @GrailsCompileStatic

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Detached Criteria and @GrailsCompileStatic

Nikola Ivanov
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?

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/daff1a3f-59a9-4160-a000-997a94f8ae64%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Detached Criteria and @GrailsCompileStatic

Jeff Brown

> On Mar 18, 2016, at 10:13 AM, Nikola Ivanov <[hidden email]> wrote:
>
> 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.
>

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/

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/E607EC5E-93B6-40CF-9809-2E05556A25DF%40ociweb.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Detached Criteria and @GrailsCompileStatic

Nikola Ivanov
Yes that one compiles just fine.

Thanks for the tip.

BR,
Nikola

On Friday, March 18, 2016 at 5:50:06 PM UTC+1, Jeff Scott Brown wrote:

> On Mar 18, 2016, at 10:13 AM, Nikola Ivanov <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="oao35UXnBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">nikola....@...> wrote:
>
> 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.
>

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.
<a href="http://www.ociweb.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\75http%3A%2F%2Fwww.ociweb.com%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNGmJq4FzWg40kVUyr9KFZMiSj7t1Q&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\75http%3A%2F%2Fwww.ociweb.com%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNGmJq4FzWg40kVUyr9KFZMiSj7t1Q&#39;;return true;">http://www.ociweb.com/

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
<a href="http://www.autismspeaks.org/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\75http%3A%2F%2Fwww.autismspeaks.org%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHLOilSQBYB1lzLN6Ms6K6DtQY5DQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\75http%3A%2F%2Fwww.autismspeaks.org%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHLOilSQBYB1lzLN6Ms6K6DtQY5DQ&#39;;return true;">http://www.autismspeaks.org/

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/ffdb9aa7-c7b8-46f6-a8fc-80cdc379f4c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...