{"record":{"id":"64ef52c1d6f5300c","repo":"hibernate/hibernate-orm","slug":"parameter-not-of-expected-type-rettype-getname","errorCode":null,"errorMessage":"Parameter not of expected type: {retType.getName()}","messagePattern":"Parameter not of expected type: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/internal/AbstractCommonQueryContract.java","lineNumber":1660,"sourceCode":"\t\t\t}\n\t\t\tcatch (PropertyNotFoundException pnfe) {\n\t\t\t\t// ignore\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\tprotected <T> Type<T> determineType(String namedParam, Class<? extends T> retType) {\n\t\tvar type = getQueryParameterBindings().getBinding( namedParam ).getBindType();\n\t\tif ( type == null ) {\n\t\t\ttype = getParameterMetadata().getQueryParameter( namedParam ).getHibernateType();\n\t\t}\n\t\tif ( type == null && retType != null ) {\n\t\t\ttype = getSessionFactory().getMappingMetamodel().resolveParameterBindType( retType );\n\t\t}\n\t\tif ( retType != null && !retType.isAssignableFrom( type.getJavaType() ) ) {\n\t\t\t// TODO: is this really the correct exception type?\n\t\t\tthrow new IllegalStateException( \"Parameter not of expected type: \" + retType.getName() );\n\t\t}\n\t\t//noinspection unchecked\n\t\treturn (Type<T>) type;\n\t}\n\n\n\n\n\t// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\t// Execution\n\n\tprivate FlushMode sessionFlushMode;\n\tprivate CacheMode sessionCacheMode;\n\n\t@Nonnull\n\tprotected abstract QueryOptions getQueryOptions();\n\n\t/// hook for subtypes","sourceCodeStart":1642,"sourceCodeEnd":1678,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/internal/AbstractCommonQueryContract.java#L1642-L1678","documentation":"Error \"Parameter not of expected type: {retType.getName()}\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A parameter is bound with a value or type incompatible with its declared type: Parameter not of expected type: <value>","commonSituations":"Binding a Java value whose type does not match the parameter's declared Hibernate/Java type, or passing a mismatched Class/TypedParameterValue to setParameter().","solutions":["The parameter is not of the expected type. Bind a value whose type matches the declared parameter type."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}