{"record":{"id":"89a16948d8795284","repo":"hibernate/hibernate-orm","slug":"wrap-strategy-not-known-for-this-java-type-ge-89a169","errorCode":null,"errorMessage":"Wrap strategy not known for this Java type: \" + getTypeName()","messagePattern":"Wrap strategy not known for this Java type: \" \\+ getTypeName\\(\\)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/type/descriptor/java/spi/JavaTypeBasicAdaptor.java","lineNumber":49,"sourceCode":"\t\t\t\t\"Could not determine recommended JdbcType for '\" + getTypeName() + \"'\"\n\t\t);\n\t}\n\n\t@Override\n\tpublic boolean useObjectEqualsHashCode() {\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic <X> X unwrap(T value, Class<X> type, WrapperOptions options) {\n\t\tthrow new UnsupportedOperationException(\n\t\t\t\t\"Unwrap strategy not known for this Java type: \" + getTypeName()\n\t\t);\n\t}\n\n\t@Override\n\tpublic <X> T wrap(X value, WrapperOptions options) {\n\t\tthrow new UnsupportedOperationException(\n\t\t\t\t\"Wrap strategy not known for this Java type: \" + getTypeName()\n\t\t);\n\t}\n\n\t@Override\n\tpublic String toString() {\n\t\treturn \"JavaTypeBasicAdaptor(\" + getTypeName() + \")\";\n\t}\n}\n","sourceCodeStart":31,"sourceCodeEnd":59,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/spi/JavaTypeBasicAdaptor.java#L31-L59","documentation":"The write-back mirror of unwrap: JavaTypeBasicAdaptor.wrap() throws UnsupportedOperationException because a bare adaptor cannot construct values. Reading a column into an attribute backed only by an adaptor — with no converter or JdbcType doing the hydration — fails here.","triggerScenarios":"Result-set hydration of an attribute whose descriptor is a bare adaptor; generic wrap() calls in custom JdbcTypes; registrations that supplied type identity but no conversion behavior.","commonSituations":"Same root cause as the unwrap variant: incomplete custom type registrations, scaffolding types left in mappings, or integrations assuming default conversion exists.","solutions":["Provide the JdbcType/converter side so wrap() is bypassed entirely","Implement wrap() in a proper AbstractClassJavaType subclass","Replace the adaptor registration with a complete BasicType (JavaType + JdbcType pair)"],"exampleFix":"// before\nMoney m = javaType.wrap(resultSet.getString(1), options); // adaptor -> throws\n\n// after\nMoney m = Money.parse(resultSet.getString(1)); // converter/JavaType owns conversion","handlingStrategy":"type-guard","validationCode":"static boolean hasRealWrap(JavaType<?> jt) {\n    return !(jt instanceof org.hibernate.type.descriptor.java.spi.JavaTypeBasicAdaptor);\n}","typeGuard":"static boolean wrapSafe(JavaType<?> javaType) {\n    return !(javaType instanceof org.hibernate.type.descriptor.java.spi.JavaTypeBasicAdaptor);\n}","tryCatchPattern":"try {\n    T v = javaType.wrap(raw, options);\n} catch (UnsupportedOperationException e) {\n    // hydrate manually until the registration supplies conversion behavior\n    T v = manuallyHydrate(raw, javaType.getJavaTypeClass());\n}","preventionTips":["Register conversion behavior, not just type identity","Audit custom types for unimplemented adaptor methods","Smoke-test full write/read round trips for every custom type"],"tags":["hibernate","orm","wrap","custom-type"],"backgroundTag":"unsupported-type-conversion","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}