hibernate/hibernate-orm · error · ConversionException
Could not determine ValueMapping for SqmExpression: {}
Error message
Could not determine ValueMapping for SqmExpression: {} What it means
determineValueMapping could not resolve a MappingModelExpressible for an SqmExpression: it found no value mapping for the expression itself and no inferred type on the inferrable-type stack. Literals are explicitly tolerated (null is returned), but every other unmappable expression aborts translation with a ConversionException echoing the expression.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/query/sqm/sql/spi/BaseSqmToSqlAstConverter.java:6524
}
final var valueMapping =
domainModel.resolveMappingExpressible( nodeType, fromClauseIndex::getTableGroup );
if ( valueMapping == null ) {
final var mappingModelExpressible = resolveInferredType();
if ( mappingModelExpressible != null ) {
return mappingModelExpressible;
}
}
if ( valueMapping == null ) {
// For literals, it is totally possible that we can't figure out a mapping type
if ( sqmExpression instanceof SqmLiteral<?> ) {
return null;
}
throw new ConversionException( "Could not determine ValueMapping for SqmExpression: " + sqmExpression );
}
return valueMapping;
}
protected MappingModelExpressible<?> getInferredValueMapping() {
final var inferredMapping = resolveInferredType();
if ( inferredMapping != null ) {
if ( inferredMapping instanceof PluralAttributeMapping pluralAttributeMapping ) {
return pluralAttributeMapping.getElementDescriptor();
}
if ( inferredMapping instanceof TupleMappingModelExpressible tuple ) {
final var elementExpressible =
tuple.findComponentMappingModelExpressible( CollectionPart.Nature.ELEMENT.getName() );
return elementExpressible == null ? inferredMapping : elementExpressible;
}
else if ( !( inferredMapping instanceof JavaObjectType ) ) {
// Never report back the "object type" as inferred type and instead rely on the value typeView on GitHub (pinned to fad1729dce)
Solutions
- Give the expression a type to infer from: 'cast(null as Integer)', 'coalesce(x, 0)' with typed branches
- Use typed parameters (cb.parameter(Integer.class)) instead of raw Object ones
- Reference a mapped path on one side of the expression so the other side can be inferred
- Simplify the expression tree - split compound arithmetic into steps Hibernate can type
Example fix
// before select o.id, null from Ord o order by 2 // after select o.id, cast(null as Integer) from Ord o
Defensive patterns
Strategy: try-catch
Validate before calling
// For dynamic criteria projections: reject expressions without a resolvable Java type
Expression<?> sel = ...;
if (sel.getJavaType() == Object.class || sel.getJavaType() == null) {
throw new IllegalArgumentException("Projection lacks a concrete type; wrap with cb.cast(...));");
} Try / catch
try {
return session.createQuery(cq).getResultList();
} catch (org.hibernate.query.sqm.tree.SqmConversionException | RuntimeException e) {
// ConversionException extends HibernateException; detect by class name to stay import-safe
if (e.getClass().getSimpleName().equals("ConversionException")) {
log.error("Unresolvable expression type in criteria query", e);
}
throw e;
} Prevention
- Never leave a bare null in projections - always cast(null as T)
- Type every parameter and avoid Object-typed expressions in criteria trees
- Keep at least one mapped path on one side of parameterized predicates
When it happens
Trigger: An untyped 'null' in the select list or order-by with nothing to infer the type from; criteria expressions typed Object; arithmetic over expressions whose operand types cannot be resolved (e.g. parameters of unknown type on both sides); comparing a subquery result that itself has no mapping.
Common situations: Dynamic criteria queries building projections from loosely typed expressions; HQL with coalesce/cast of null without a typed second branch; mixing parameters of raw types in predicates; queries that worked on older 6.x and break after inference changes.
Related errors
- Couldn't determine types of arguments to function 'generate_
- Couldn't determine types of arguments to function 'generate_
- Insert conflict 'do update' clause with constraint name is n
- Summarization is not supported by DBMS
- Insert conflict 'do update' clause with constraint name is n
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/70629da7d4c83fcb.
Report an issue: GitHub.