Quantcast

HibernateCriteriaBuilder#createAlias gives 'IllegalArgumentException: argument type mismatch" with GStrings

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

HibernateCriteriaBuilder#createAlias gives 'IllegalArgumentException: argument type mismatch" with GStrings

Bob Brown
Note the use of .toString() in the snippet below:

///
        def boards = Board.withCriteria {
            eq('yearmonth', yearmonth)
            isNotNull('practice')

            or {
                for (pocket in 6..40)
                    and {
                        createAlias("pocket${pocket}".toString(),
"p${pocket}".toString(), CriteriaSpecification.LEFT_JOIN)
                        eq("pocket${pocket}", brochure)
                        eq("p${pocket}.type", 'pocket')
                    }
                for (mag in 1..2) {
                    and {
                        createAlias("magazine${mag}".toString(),
"m${mag}".toString(), CriteriaSpecification.LEFT_JOIN)
                        eq("magazine${mag}", brochure)
                    }
                }
            }
        }
///

Without these (just using the GStrings directly), I get an exception:

---
java.lang.IllegalArgumentException: argument type mismatch
        at
grails.orm.HibernateCriteriaBuilder.invokeMethod(HibernateCriteriaBuilder.ja
va:1571)
        at
BrochureUptakeByPostcodeReportService$_report_closure2_closure10_closure11.d
oCall(BrochureUptakeByPostcodeReportService.groovy:61)
        at
grails.orm.HibernateCriteriaBuilder.invokeClosureNode(HibernateCriteriaBuild
er.java:1780)
        at
grails.orm.HibernateCriteriaBuilder.invokeMethod(HibernateCriteriaBuilder.ja
va:1589)
        at
BrochureUptakeByPostcodeReportService$_report_closure2_closure10.doCall(Broc
hureUptakeByPostcodeReportService.groovy:60)
        at
grails.orm.HibernateCriteriaBuilder.invokeClosureNode(HibernateCriteriaBuild
er.java:1780)
        at
grails.orm.HibernateCriteriaBuilder.invokeMethod(HibernateCriteriaBuilder.ja
va:1589)
        at
BrochureUptakeByPostcodeReportService$_report_closure2.doCall(BrochureUptake
ByPostcodeReportService.groovy:58)
        at
grails.orm.HibernateCriteriaBuilder.invokeClosureNode(HibernateCriteriaBuild
er.java:1780)
        at
grails.orm.HibernateCriteriaBuilder.invokeMethod(HibernateCriteriaBuilder.ja
va:1481)
        at
org.grails.datastore.gorm.GormStaticApi.withCriteria(GormStaticApi.groovy:26
1)
        at
BrochureUptakeByPostcodeReportService.report(BrochureUptakeByPostcodeReportS
ervice.groovy:54)
        at ReportController.report(ReportController.groovy:190)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.ja
va:886)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:9
08)
        at java.lang.Thread.run(Thread.java:662)
---

Cheers,

BOB


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Loading...