Class JpqlParameterConversionService
Each JpqlExecutionParameter carries a declared type name and an untyped value (typically
a string or a number as produced by the LLM). This service resolves the target Java class and
coerces the value to it, supporting common JDK types and any type known to the
DatatypeRegistry. Values whose type cannot be resolved are passed through unchanged.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@Nullable Objectconvert(JpqlExecutionParameter parameter) Converts a single parameter's value to its declared Java type.convert(@Nullable List<JpqlExecutionParameter> parameters) Converts a list of parameters to a name-to-value map of execution-ready values, preserving order.convertCollection(Collection<?> values, Class<?> targetClass) Converts every element of a collection parameter to the target type, preserving order.protected @Nullable ObjectconvertNumberValue(Number value, Class<?> targetClass) protected @Nullable ObjectconvertScalar(@Nullable Object value, Class<?> targetClass) Converts a single scalar value to the target type, leaving it unchanged when it is already an instance of the target type or cannot be coerced.protected @Nullable ObjectconvertStringValue(String value, Class<?> targetClass) protected @Nullable Class<?> resolveJavaClass(@Nullable String type) protected @Nullable Class<?> Resolves a type name against theDatatypeRegistry, matching a registered datatype by its Java class name (simple or fully qualified).
-
Field Details
-
datatypeRegistry
-
-
Constructor Details
-
JpqlParameterConversionService
public JpqlParameterConversionService()
-
-
Method Details
-
convert
Converts a list of parameters to a name-to-value map of execution-ready values, preserving order.Parameters whose value converts to
nullare skipped rather than bound.- Parameters:
parameters- parameters to convert- Returns:
- map of parameter names to converted values; parameters with a
nullvalue are omitted
-
convert
Converts a single parameter's value to its declared Java type.Collection values (used for
INclauses) are converted element by element to the declared type, so e.g. a list of UUID strings becomes a list ofUUIDs.- Parameters:
parameter- parameter whose value is converted- Returns:
- the converted value, or
nullif the parameter value isnull - Throws:
IllegalArgumentException- if the value cannot be parsed as the declared type
-
convertScalar
Converts a single scalar value to the target type, leaving it unchanged when it is already an instance of the target type or cannot be coerced.- Parameters:
value- scalar value to convert, ornulltargetClass- type to convert the value to- Returns:
- the converted value, or
nullifvalueisnull - Throws:
IllegalArgumentException- if the value cannot be parsed as the target type
-
convertCollection
Converts every element of a collection parameter to the target type, preserving order.A
nullelement is kept asnull— that is an explicitnullin the source (e.g. produced by the LLM), and it is legitimate to bind it. If a non-nullelement instead converts tonull— i.e. the conversion silently lost the value — this is treated as a conversion failure and reported, so it cannot quietly become aNULLoperand that never matches in theINclause.- Parameters:
values- collection values to convert (e.g. the operands of anINclause)targetClass- type to convert each element to- Returns:
- a list of converted elements; an element is
nullonly if it wasnullto begin with - Throws:
IllegalArgumentException- if a non-nullelement converts tonull, or if an element cannot be parsed as the target type
-
convertStringValue
-
convertNumberValue
-
resolveJavaClass
-
resolveRegisteredDatatypeClass
Resolves a type name against theDatatypeRegistry, matching a registered datatype by its Java class name (simple or fully qualified).- Parameters:
type- declared type name (a Java class simple name or fully qualified name)- Returns:
- the matching registered datatype's Java class, or
nullif none matches
-