rest - grails 3 overriding queryForResource not working -
according grails web services
i can override method queryforresource. way may able specify nested rest resource. e.g
"/authors"(resources:'author') { "/books"(resources:'book') }
but doc may wrong. because uses assigment operator = instead comparison 1 ==.
running way following error:
((id == id) && building.id) binary expression, should variable expression
changing operator = == error
cannot query property "params" - no such property on class clash.buildinglevel exists
what correct way define nested rest resource?
here queryforresource method:
i tried both:
@override protected buildinglevel queryforresource(serializable id) { if (params.buildingid) { return buildinglevel.where { id == id && building.id = params.buildingid }.find() } } @override protected buildinglevel queryforresource(serializable id) { if (params.buildingid) { return buildinglevel.where { id == id && building.id == params.buildingid }.find() } }
i figure out.
the following post issues-posting-nested-resource-in-grails helped me.
the params cannot inside where clause. it's necessary create local variable keep value. this:
@override protected buildinglevel queryforresource(serializable id) { def mylocalvariablebuildingid = params.buildingid if (params.buildingid) { return buildinglevel.where { id == id && building.id == mylocalvariablebuildingid }.find() } }
Comments
Post a Comment