{"record":{"id":"04f94cda1229970e","repo":"hibernate/hibernate-orm","slug":"usertype-implementation-type-getclass-get","errorCode":null,"errorMessage":"'UserType' implementation '\" + type.getClass().getName() + \"' does not implement 'ParameterizedType' or 'AnnotationBasedUserType' but parameters were provided","messagePattern":"'UserType' implementation '\" \\+ type\\.getClass\\(\\)\\.getName\\(\\) \\+ \"' does not implement 'ParameterizedType' or 'AnnotationBasedUserType' but parameters were provided","errorType":"exception","errorClass":"MappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/mapping/MappingHelper.java","lineNumber":81,"sourceCode":"\t\t\telse {\n\t\t\t\tthrowIgnoredCollectionTypeParameters( role, userCollectionTypeClass );\n\t\t\t}\n\t\t}\n\t\treturn managedBean;\n\t}\n\n\tprivate static void throwIgnoredCollectionTypeParameters(String role, Class<?> implementation) {\n\t\tthrow new MappingException( \"'@CollectionType' [\" + role + \"] specified parameters, but the implementation '\"\n\t\t\t\t+ implementation.getName() + \"' does not implement 'ParameterizedType' which is used to inject them\" );\n\t}\n\n\tpublic static void injectParameters(Object type, Properties parameters) {\n\t\tif ( type instanceof ParameterizedType parameterizedType ) {\n\t\t\tparameterizedType.setParameterValues( parameters == null ? EMPTY_PROPERTIES : parameters );\n\t\t}\n\t\telse if ( parameters != null && !parameters.isEmpty()\n\t\t\t\t&& !( type instanceof AnnotationBasedUserType<?,?> ) ) {\n\t\t\tthrow new MappingException( \"'UserType' implementation '\" + type.getClass().getName()\n\t\t\t\t\t+ \"' does not implement 'ParameterizedType' or 'AnnotationBasedUserType' but parameters were provided\" );\n\t\t}\n\t}\n\n\tprivate static ManagedBean<UserCollectionType> createLocalUserTypeBean(\n\t\t\tString role,\n\t\t\tClass<? extends UserCollectionType> implementation,\n\t\t\tMap<String, ?> parameters) {\n\t\tfinal var userCollectionType =\n\t\t\t\tFallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( implementation );\n\t\tif ( isNotEmpty( parameters ) ) {\n\t\t\t// CollectionType declared parameters - inject them\n\t\t\tif ( userCollectionType instanceof ParameterizedType parameterizedType ) {\n\t\t\t\tfinal var properties = new Properties();\n\t\t\t\tproperties.putAll( parameters );\n\t\t\t\tparameterizedType.setParameterValues( properties );\n\t\t\t}\n\t\t\telse {","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/mapping/MappingHelper.java#L63-L99","documentation":"MappingHelper#injectParameters throws when a custom UserType receives non-empty parameters but implements neither ParameterizedType (to receive them programmatically) nor AnnotationBasedUserType (to receive the annotation instance). The parameters simply have nowhere to go.","triggerScenarios":"@Type(value = X.class, parameters = @Param(...)) or hbm <type name=\"X\"><param>...</param></type> where X is a plain UserType; migrating parameterized hbm types to annotations; adding <param> entries to an existing type that ignores them.","commonSituations":"Legacy UserType implementations that predate parameter support; supplying configuration (enum prefix, varchar length, format) to a type that was not built to read it.","solutions":["Implement org.hibernate.usertype.ParameterizedType on the UserType (setParameterValues) and consume the parameters.","Or extend AnnotationBasedUserType to read configuration from the annotation instance itself.","Or delete the parameters - they cannot reach a type that accepts none."],"exampleFix":"// before\n@Type(value = MyStringType.class,\n      parameters = @Param(name = \"k\", value = \"v\"))\nprivate String note; // MyStringType implements only UserType\n\n// after\npublic class MyStringType implements UserType<String>, ParameterizedType {\n    @Override\n    public void setParameterValues(Properties parameters) { ... }\n}","handlingStrategy":"validation","validationCode":"static boolean userTypeAcceptsParameters(UserType<?> type) {\n    return type instanceof org.hibernate.usertype.ParameterizedType\n            || type instanceof AnnotationBasedUserType;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Implement ParameterizedType in the base class of every custom UserType that may be configured.","Only attach @Param parameters to types that declare they consume them.","Use AnnotationBasedUserType when configuration should come from the annotation itself."],"tags":["hibernate","orm","mapping","user-type","parameters","type-annotation"],"backgroundTag":"type-parameters-not-supported","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}