Quantcast

Left Join (alias) in Criteria for Grails 2.0 -- NEED HELP !

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

Left Join (alias) in Criteria for Grails 2.0 -- NEED HELP !

Martin Saucier-2
Allright, I need to use the following alias in order to join the vehicleCustomers relationship as a LEFT OUTER JOIN (because of the changes to Grails 2.0 from Left Join to Inner Join default behaviour), however the following criteria query produces the Hibernate error below. It looks like the we can't use the defined alias 'vc' as a mapping relationship ? Any idea on how I could fix that ?

List<Vehicle> results = ShopVehicle.createCriteria().list {
createAlias('vehicleCustomers', 'vc', CriteriaSpecification.LEFT_JOIN)
dealership { eq('id', dealershipId) }
or {
rlike("searchValue", "(" + criteria.trim() + ")")
vc {
customer {
rlike("searchValue", "(" + criteria.trim() + ")")
}
}
}
maxResults(50)
}


groovy.lang.MissingMethodException: No signature of method: grails.orm.HibernateCriteriaBuilder.vc() is applicable for argument types: (com.vinvox.vip.ShopVehicle$_search_closure2_closure6_closure7_closure8) values: [com.vinvox.vip.ShopVehicle$_search_closure2_closure6_closure7_closure8@605d3821]
Possible solutions: id(), avg(java.lang.String), is(java.lang.Object), any(), avg(java.lang.String, java.lang.String), eq(java.lang.String, java.lang.Object)
at grails.orm.HibernateCriteriaBuilder.invokeMethod(HibernateCriteriaBuilder.java:1649)
at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1119)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:979)


Martin Saucier
Solutions Architect
t 506.874.8906

 



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Left Join (alias) in Criteria for Grails 2.0 -- NEED HELP !

Martin Saucier-2
Anyone running into this issue ? It's a real blocker right now unless I re-write this GORM query into an HQL query. Regardless, this should be valid right ?

On 2011-12-21, at 11:09 AM, Martin Saucier wrote:

Allright, I need to use the following alias in order to join the vehicleCustomers relationship as a LEFT OUTER JOIN (because of the changes to Grails 2.0 from Left Join to Inner Join default behaviour), however the following criteria query produces the Hibernate error below. It looks like the we can't use the defined alias 'vc' as a mapping relationship ? Any idea on how I could fix that ?

List<Vehicle> results = ShopVehicle.createCriteria().list {
createAlias('vehicleCustomers', 'vc', CriteriaSpecification.LEFT_JOIN)
dealership { eq('id', dealershipId) }
or {
rlike("searchValue", "(" + criteria.trim() + ")")
vc {
customer {
rlike("searchValue", "(" + criteria.trim() + ")")
}
}
}
maxResults(50)
}


groovy.lang.MissingMethodException: No signature of method: grails.orm.HibernateCriteriaBuilder.vc() is applicable for argument types: (com.vinvox.vip.ShopVehicle$_search_closure2_closure6_closure7_closure8) values: [com.vinvox.vip.ShopVehicle$_search_closure2_closure6_closure7_closure8@605d3821]
Possible solutions: id(), avg(java.lang.String), is(java.lang.Object), any(), avg(java.lang.String, java.lang.String), eq(java.lang.String, java.lang.Object)
at grails.orm.HibernateCriteriaBuilder.invokeMethod(HibernateCriteriaBuilder.java:1649)
at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1119)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:979)


Martin Saucier
Solutions Architect
t 506.874.8906

 


<image001.gif>


Martin Saucier
Solutions Architect
t 506.874.8906

 



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Left Join (alias) in Criteria for Grails 2.0 -- NEED HELP !

dangar
In reply to this post by Martin Saucier-2
I did not try but maybe something like this could work.

                List<Vehicle> results = ShopVehicle.createCriteria().list {
                        createAlias('vehicleCustomers', 'vc', CriteriaSpecification.LEFT_JOIN)
                        createAlias('vc.customer', 'cu', CriteriaSpecification.INNER_JOIN)
                        dealership { eq('id', dealershipId) }
                        or {
                                rlike("searchValue", "(" + criteria.trim() + ")")
                                rlike("cu.searchValue", "(" + criteria.trim() + ")")
                        }
                        maxResults(50)
                }
Loading...