Class JpqlParameterConversionService
java.lang.Object
io.jmix.aitools.dataload.execution.JpqlParameterConversionService
@NullMarked
@Component("aitls_JpqlParameterConversionService")
public class JpqlParameterConversionService
extends Object
Converts raw JPQL parameter values to the Java types expected by the query.
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 andnullelements.protected @Nullable ObjectconvertNumberValue(Number value, Class<?> targetClass) protected @Nullable ObjectconvertScalar(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<?> resolveJavaClassByName(String type)
-
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 converttargetClass- type to convert the value to- Returns:
- the converted value
- 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 andnullelements.- 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
-
convertStringValue
-
convertNumberValue
-
resolveJavaClass
-
resolveJavaClassByName
-