This is an automated email from the ASF dual-hosted git repository. borinquenkid pushed a commit to branch 8.0.x-hibernate7-dev in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 61e1cf83dbc3cf021c4af730ce13ac6c9e23ee98 Author: Walter Duque de Estrada <[email protected]> AuthorDate: Tue Mar 17 11:01:47 2026 -0500 PredicateGenerator throws correct exception --- .../grails/orm/hibernate/query/PredicateGenerator.java | 3 ++- .../specs/hibernatequery/PredicateGeneratorSpec.groovy | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/PredicateGenerator.java b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/PredicateGenerator.java index b00da8152d..21948dfd14 100644 --- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/PredicateGenerator.java +++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/PredicateGenerator.java @@ -463,7 +463,8 @@ public class PredicateGenerator { if (value instanceof Number num) return num; if (value != null && conversionService.canConvert(value.getClass(), Number.class)) { try { - return conversionService.convert(value, Number.class); + Number convert = conversionService.convert(value, Number.class); + return convert; } catch (org.springframework.core.convert.ConversionException ignored) { throw new ConfigurationException(String.format( "Operation '%s' on property '%s' only accepts a numeric value, but received a %s", diff --git a/grails-data-hibernate7/core/src/test/groovy/grails/gorm/specs/hibernatequery/PredicateGeneratorSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/grails/gorm/specs/hibernatequery/PredicateGeneratorSpec.groovy index f44f6eec9e..5e4c70c1b8 100644 --- a/grails-data-hibernate7/core/src/test/groovy/grails/gorm/specs/hibernatequery/PredicateGeneratorSpec.groovy +++ b/grails-data-hibernate7/core/src/test/groovy/grails/gorm/specs/hibernatequery/PredicateGeneratorSpec.groovy @@ -522,4 +522,22 @@ class PredicateGeneratorSpec extends HibernateGormDatastoreSpec { noExceptionThrown() predicates.length == 1 } + + def "test gt with String value that cant be coerced to Number"() { + given: + List criteria = [new Query.GreaterThan("age", "Bobby")] + when: + def predicates = predicateGenerator.getPredicates(cb, query, root, criteria, fromProvider, personEntity) + then: + thrown(ConfigurationException) + } + + def "test lt with String value that cant be coerced to Number"() { + given: + List criteria = [new Query.LessThan("age", "Bobby")] + when: + def predicates = predicateGenerator.getPredicates(cb, query, root, criteria, fromProvider, personEntity) + then: + thrown(ConfigurationException) + } }
