fix(jpa): convert function-expression literal to the expression result type - #194
Merged
brunomendola merged 1 commit intoJul 11, 2026
Merged
Conversation
…t type A SimpleCondition whose left side is a function expression passed the raw String literal to the predicate without conversion, so date/time comparisons failed at the database (e.g. CURRENT_DATE = "2026-06-22" -> "Could not convert java.lang.String to java.sql.Date"). Plain property paths were already converted via PropertyUtils. - JpaOperatorMapper converts the literal to leftExpression.getJavaType(); when JPA cannot infer it (COALESCE/NULLIF), falls back to the first property argument's type - DateValueExtractor now parses java.sql.Date/Time/Timestamp from their ISO-8601 forms (previously only java.util.Date via Instant.parse) - PropertyValueExtractorFactory returns NoOp for a null target type - PropertyUtils.getActualValue(Class, Object) extracts the reusable per-type conversion; getActualPropertyValue delegates to it - Integration tests on H2/PostgreSQL for CURRENT_DATE and COALESCE(dateField) Refs queritylib#187 Co-Authored-By: Claude Opus 4.8 <[email protected]>
brunomendola
approved these changes
Jul 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #187: a
SimpleConditionwhose left side is a function expression passed the rawStringliteral to the predicate without conversion, so date/time comparisons failed at the database:→
Could not convert 'java.lang.String' to 'java.sql.Date' using 'org.hibernate.type.descriptor.java.JdbcDateJavaType' to wrapPlain property paths were already converted via
PropertyUtils.getActualPropertyValue; the function-expression branch usedcondition.getValue()as-is.Changes
JpaOperatorMapper— converts the literal to the left expression's result type (Expression#getJavaType()); when JPA cannot infer it (COALESCE/NULLIFreturnnullthere), falls back to the type of the first property argument; keeps the raw value if no type can be resolvedDateValueExtractor— parsesjava.sql.Date/Time/Timestampfrom their ISO-8601 forms (2026-06-22,10:15:30,2026-06-22T10:15:30); a plainjava.util.Datetarget keeps the historical ISO-instant behaviorPropertyValueExtractorFactory— returns the no-op extractor for anulltarget type (defensive)PropertyUtils— extractsgetActualValue(Class, Object)as the reusable per-type conversion;getActualPropertyValuedelegates to itTesting
QuerityJpaImplTests(run on both H2 and PostgreSQL via Testcontainers):CURRENT_DATE = "<today>"— literal converted tojava.sql.Date, matches all rowsCOALESCE(birthDate) = "<date>"— type resolved from the property argumentDateValueExtractorTestsextended with thejava.sql.*parse cases./mvnw verify— JaCoCo per-class coverage checks metFixes #187
🤖 Generated with Claude Code