{"record":{"id":"2e55a18f2c9fb8f4","repo":"hibernate/hibernate-orm","slug":"could-not-determine-neither-the-sqltypedmapping-no","errorCode":null,"errorMessage":"Could not determine neither the SqlTypedMapping nor the Bindable value for SqmParameter: {}","messagePattern":"Could not determine neither the SqlTypedMapping nor the Bindable value for SqmParameter: (.+?)","errorType":"exception","errorClass":"ConversionException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/sqm/sql/spi/BaseSqmToSqlAstConverter.java","lineNumber":6726,"sourceCode":"\t\t\t\t? jdbcParameters.getJdbcParameters().size()\n\t\t\t\t: castNonNull( jdbcParams.get( 0 ).get( 0 ).getParameterId() );\n\t\tfinal var bindable = bindable( valueMapping );\n\t\tif ( bindable instanceof SelectableMappings selectableMappings ) {\n\t\t\tselectableMappings.forEachSelectable(\n\t\t\t\t\t(index, selectableMapping)\n\t\t\t\t\t\t\t-> jdbcParameterConsumer.accept( index,\n\t\t\t\t\t\t\t\t\tnew SqlTypedMappingJdbcParameter( selectableMapping, parameterId + index ) )\n\t\t\t);\n\t\t}\n\t\telse if ( bindable instanceof SelectableMapping selectableMapping ) {\n\t\t\tjdbcParameterConsumer.accept( 0,\n\t\t\t\t\tnew SqlTypedMappingJdbcParameter( selectableMapping, parameterId ) );\n\t\t}\n\t\telse {\n\t\t\tfinal var sqlTypedMapping = sqlTypedMapping( expression, bindable );\n\t\t\tif ( sqlTypedMapping == null ) {\n\t\t\t\tif ( bindable == null ) {\n\t\t\t\t\tthrow new ConversionException(\n\t\t\t\t\t\t\t\"Could not determine neither the SqlTypedMapping nor the Bindable value for SqmParameter: \" + expression );\n\t\t\t\t}\n\t\t\t\tbindable.forEachJdbcType(\n\t\t\t\t\t\t(index, jdbcMapping) -> jdbcParameterConsumer.accept(\n\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\tnew JdbcParameterImpl( jdbcMapping, parameterId + index )\n\t\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tjdbcParameterConsumer.accept( 0,\n\t\t\t\t\t\tnew SqlTypedMappingJdbcParameter( sqlTypedMapping, parameterId ) );\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate SqlTypedMapping sqlTypedMapping(SqmParameter<?> expression, Bindable bindable) {\n\t\tif ( bindable instanceof BasicType<?> basicType) {","sourceCodeStart":6708,"sourceCodeEnd":6744,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/spi/BaseSqmToSqlAstConverter.java#L6708-L6744","documentation":"While registering JDBC parameters for a query parameter, both the bindable and the derived sqlTypedMapping were null, so no JDBC type or selectable could be attached to the parameter - translation fails with a ConversionException naming the SqmParameter. It is the binding-time surface of the same root cause as the parameter-mapping error.","triggerScenarios":"Criteria parameters with no type information reaching JDBC registration; parameters whose JpaCriteriaParameter resolution was lost (parameter object not part of the compiled tree); null bindings in positions with no inferable type; reused query objects after criteria mutation.","commonSituations":"Same contexts as untyped criteria parameters - dynamic filter builders, generic repositories, cross-query parameter reuse; often appears only at runtime on specific parameter combinations.","solutions":["Type every criteria parameter (cb.parameter with a real class) and keep each parameter inside the query that created it","Guarantee a mapped path on the other side of any parameterized predicate","Rebuild the query via createQuery after any criteria mutation instead of reusing a stale compiled query","Upgrade Hibernate - several 'Could not determine neither SqlTypedMapping nor Bindable' cases were fixed in point releases"],"exampleFix":"// before\nParameterExpression p = cb.parameter(Object.class);\nquery.where(cb.equal(root.get(\"total\"), p));\n\n// after\nParameterExpression<BigDecimal> p = cb.parameter(BigDecimal.class);\nquery.where(cb.equal(root.get(\"total\"), p));","handlingStrategy":"validation","validationCode":"// Same guard as for parameter mapping: concrete types on all criteria parameters\nboolean allTyped = query.getParameters().stream()\n    .allMatch(p -> p.getParameterType() != null && p.getParameterType() != Object.class);\nif (!allTyped) {\n    throw new IllegalStateException(\"Refusing to run query with untyped parameters\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    return query.getResultList();\n} catch (RuntimeException e) {\n    if (e.getClass().getSimpleName().equals(\"ConversionException\")\n            && e.getMessage() != null && e.getMessage().contains(\"SqlTypedMapping\")) {\n        log.error(\"JDBC parameter without type - rebuild query with typed parameters\");\n    }\n    throw e;\n}","preventionTips":["Type every parameter and rebuild queries after criteria mutations","Bind via the same query instance the parameters were created for","Stay current on Hibernate patch releases - several such inference gaps were fixed"],"tags":["hibernate","criteria","jdbc-parameter","type-inference"],"backgroundTag":"untyped-query-parameter","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}