hibernate/hibernate-orm · error · IllegalStateException

Parameter not of expected type: {retType.getName()}

Error message

Parameter not of expected type: {retType.getName()}

What it means

Error "Parameter not of expected type: {retType.getName()}" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/query/internal/AbstractCommonQueryContract.java:1660

			}
			catch (PropertyNotFoundException pnfe) {
				// ignore
			}
		}
		return this;
	}

	protected <T> Type<T> determineType(String namedParam, Class<? extends T> retType) {
		var type = getQueryParameterBindings().getBinding( namedParam ).getBindType();
		if ( type == null ) {
			type = getParameterMetadata().getQueryParameter( namedParam ).getHibernateType();
		}
		if ( type == null && retType != null ) {
			type = getSessionFactory().getMappingMetamodel().resolveParameterBindType( retType );
		}
		if ( retType != null && !retType.isAssignableFrom( type.getJavaType() ) ) {
			// TODO: is this really the correct exception type?
			throw new IllegalStateException( "Parameter not of expected type: " + retType.getName() );
		}
		//noinspection unchecked
		return (Type<T>) type;
	}




	// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Execution

	private FlushMode sessionFlushMode;
	private CacheMode sessionCacheMode;

	@Nonnull
	protected abstract QueryOptions getQueryOptions();

	/// hook for subtypes

View on GitHub (pinned to fad1729dce)

Solutions

  1. The parameter is not of the expected type. Bind a value whose type matches the declared parameter type.

When it happens

Trigger: A parameter is bound with a value or type incompatible with its declared type: Parameter not of expected type: <value>

Common situations: Binding a Java value whose type does not match the parameter's declared Hibernate/Java type, or passing a mismatched Class/TypedParameterValue to setParameter().


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/64ef52c1d6f5300c. Report an issue: GitHub.