GRAILS-10869 - improve the handling of nested url mapping

This improves on some statement management which was problematic for nested url mappings.