{"record":{"id":"5ae22b35bce18870","repo":"hibernate/hibernate-orm","slug":"support-for-model-part-type-not-yet-implemented-5ae22b","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/JsonGeneratingVisitor.java","lineNumber":269,"sourceCode":"\t\t\tvisit( modelPart.getMappedType(), value, options, writer );\n\t\t}\n\t\telse if ( modelPart instanceof EmbeddedAttributeMapping embeddedAttribute ) {\n\t\t\tif ( value != null ) {\n\t\t\t\tfinal EmbeddableMappingType mappingType = embeddedAttribute.getMappedType();\n\t\t\t\tfinal SelectableMapping aggregateMapping = mappingType.getAggregateMapping();\n\t\t\t\tif ( aggregateMapping == null ) {\n\t\t\t\t\tserializeObjectValues( mappingType, value, options, writer );\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tfinal String name = aggregateMapping.getSelectableName();\n\t\t\t\t\twriter.objectKey( name );\n\t\t\t\t\tvisit( mappingType, value, options, writer );\n\t\t\t\t}\n\t\t\t}\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\tprotected void serializeEntity(\n\t\t\tObject value,\n\t\t\tEntityMappingType entityType,\n\t\t\tWrapperOptions options,\n\t\t\tJsonDocumentWriter writer) throws IOException {\n\t\t// We only need the identifier here\n\t\tfinal EntityIdentifierMapping identifierMapping = entityType.getIdentifierMapping();\n\t\tserializeEntityIdentifier( value, identifierMapping, options, writer );\n\t}\n\n\tprotected void serializeEntityIdentifier(\n\t\t\tObject value,","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/spi/JsonGeneratingVisitor.java#L251-L287","documentation":"While flattening an embeddable into JSON, serializeObjectValues walks each sub-part (getSubPart) and hands it to serializeModelPart. Only two model-part shapes are serializable: SelectableMapping (plain column-backed values, written as key + visit) and EmbeddedAttributeMapping (nested embeddables). Anything else - to-one associations, plural attributes, @Any mappings, custom ValuedModelPart implementations - has no JSON key/value form, so Hibernate throws UnsupportedOperationException with the model part class name, or 'null' when the part itself is null.","triggerScenarios":"An @Embeddable stored as a JSON aggregate (e.g. @JdbcTypeCode(SqlTypes.JSON) on an @Embedded attribute for PostgreSQL jsonb / Oracle JSON) that declares @ManyToOne, @OneToOne, @Any or a collection field; during flush or query-result writing the association's model part (e.g. ToOneAttributeMapping) reaches serializeModelPart and is rejected.","commonSituations":"Reusing domain embeddables originally written for plain relational mapping inside JSON columns; retrofitting JSON storage onto an existing model that keeps entity references inside value objects.","solutions":["Remove the association field from the JSON-mapped embeddable or annotate it @Transient","Replace the association inside the embeddable with a plain FK column (e.g. Long otherId), which is a basic SelectableMapping and serializes fine","Keep associations on the owning entity instead of inside the aggregate","Upgrade Hibernate ORM in case additional model parts became serializable"],"exampleFix":"// before\n@Embeddable\nclass Address {\n    @ManyToOne\n    private Country country; // association inside JSON aggregate -> 'Support for model part type not yet implemented'\n}\n\n// after\n@Embeddable\nclass Address {\n    @Column(name = \"country_id\")\n    private Long countryId; // basic FK column serializes as a JSON value\n}","handlingStrategy":"validation","validationCode":"// Fail fast at startup: scan embeddables used in JSON aggregates for association fields\nfor (Field f : embeddableClass.getDeclaredFields()) {\n    if (f.isAnnotationPresent(ManyToOne.class) || f.isAnnotationPresent(OneToOne.class)\n            || f.isAnnotationPresent(Any.class) || f.isAnnotationPresent(OneToMany.class)\n            || f.isAnnotationPresent(ManyToMany.class)) {\n        if (!f.isAnnotationPresent(Transient.class)) {\n            throw new IllegalStateException(\"Association inside JSON-mapped embeddable: \" + f);\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep associations out of embeddables stored as JSON - store plain FK columns instead","Mark non-persisted helper fields @Transient","Round-trip every aggregate mapping (persist + load) in integration tests before shipping"],"tags":["hibernate","json","embeddable","aggregate-mapping","association"],"backgroundTag":"json-embeddable-unsupported-part","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}