When passing parameters to the dynamic finders on Grails domain classes the parameters are dynamically typed. This allows for automatic type conversion, by Groovy.
In your example, Groovy is seeing that the barValue is of type Long and is casting the String value to a Long.
JN3015-Types explains this behavior of Groovy a bit further with some examples.