{"record":{"id":"d0b5bc86fce81a88","repo":"hibernate/hibernate-orm","slug":"support-for-model-part-type-not-yet-implemented","errorCode":null,"errorMessage":"Support for model part type not yet implemented: ","messagePattern":"Support for model part type not yet implemented: ","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/spi/DescriptiveJsonGeneratingVisitor.java","lineNumber":124,"sourceCode":"\t\tif ( modelPart instanceof SelectableMapping ) {\n\t\t\twriter.objectKey( modelPart.getPartName() );\n\t\t\tvisit( modelPart.getMappedType(), value, options, writer );\n\t\t}\n\t\telse if ( modelPart instanceof EmbeddedAttributeMapping embeddedAttribute ) {\n\t\t\twriter.objectKey( embeddedAttribute.getAttributeName() );\n\t\t\tvisit( embeddedAttribute.getMappedType(), value, options, writer );\n\t\t}\n\t\telse if ( modelPart instanceof EntityValuedModelPart entityPart ) {\n\t\t\twriter.objectKey( entityPart.getPartName() );\n\t\t\tvisit( entityPart.getEntityMappingType(), value, options, writer );\n\t\t}\n\t\telse if ( modelPart instanceof PluralAttributeMapping plural ) {\n\t\t\twriter.objectKey( plural.getPartName() );\n\t\t\tserializePluralAttribute( value, plural, options, writer );\n\t\t}\n\t\telse {\n\t\t\t// could not handle model part, throw exception\n\t\t\tthrow new UnsupportedOperationException(\n\t\t\t\t\t\"Support for model part type not yet implemented: \"\n\t\t\t\t\t+ (modelPart != null ? modelPart.getClass().getName() : \"null\")\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate void serializePluralAttribute(\n\t\t\tObject value,\n\t\t\tPluralAttributeMapping plural,\n\t\t\tWrapperOptions options,\n\t\t\tJsonDocumentWriter writer) throws IOException {\n\t\tif ( handleNullOrLazy( value, writer ) ) {\n\t\t\t// nothing left to do\n\t\t\treturn;\n\t\t}\n\n\t\tfinal CollectionPart element = plural.getElementDescriptor();\n\t\tfinal CollectionSemantics<?, ?> collectionSemantics = plural.getMappedType().getCollectionSemantics();","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/spi/DescriptiveJsonGeneratingVisitor.java#L106-L142","documentation":"The descriptive JSON serializer handles four model-part kinds: basic selectables, embedded attributes, entity-valued parts, and plural attributes. Any other ModelPart on the entity path - most commonly a @Any DiscriminatedAssociationAttributeMapping - throws UnsupportedOperationException with the part class name (or 'null').","triggerScenarios":"Hibernate Assistant (or any consumer of DescriptiveJsonGeneratingVisitor) serializes an entity that contains an @Any or @AnyDiscriminator mapping, or another exotic model part not covered by the four supported kinds.","commonSituations":"Entities with polymorphic @Any references included in query results exported to JSON; enriching legacy models with any-style associations; new Hibernate versions adding model-part kinds the visitor has not learned yet.","solutions":["Replace the @Any mapping with a regular @ManyToOne to a mapped hierarchy.","Exclude entities carrying @Any from descriptive JSON export (select a projection instead).","Upgrade Hibernate: visitor coverage expands over versions; report the missing part class in a Jira issue."],"exampleFix":"// before\n@Any\n@JoinColumn(name = \"owner_id\")\n@AnyDiscriminator(DiscriminatorType.STRING)\n@AnyKeyJavaType(Long.class)\nprivate Serializable owner;   // -> Support for model part type not yet implemented\n// after: plain association to a mapped hierarchy\n@ManyToOne(fetch = FetchType.LAZY)\n@JoinColumn(name = \"owner_id\")\nprivate Party owner;","handlingStrategy":"validation","validationCode":"static void assertDescriptiveSerializable(Class<?> entity) {\n    for (Field f : entity.getDeclaredFields()) {\n        if (f.isAnnotationPresent(Any.class)) {\n            throw new IllegalStateException(\n                \"@Any attribute not supported by descriptive JSON: \" + f);\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    return resultsJsonSerializer.toJson(resultList);\n} catch (UnsupportedOperationException ex) {\n    if (ex.getMessage() != null && ex.getMessage().startsWith(\"Support for model part type\")) {\n        // entity carries an exotic part (e.g. @Any); fall back to a projection\n        return serializeProjection(resultList);\n    }\n    throw ex;\n}","preventionTips":["Prefer regular @ManyToOne associations over @Any on entities exposed to tooling serialization.","Smoke-test descriptive JSON export against the real entity metamodel after model changes.","Track Hibernate release notes for visitor coverage of new model-part kinds."],"tags":["hibernate","json","serialization","any-mapping","tooling"],"backgroundTag":"unsupported-mapping-type","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}