hibernate/hibernate-orm · error · UnsupportedOperationException

Support for mapping type not yet implemented:

Error message

Support for mapping type not yet implemented: 

What it means

JsonGeneratingVisitor.visit() is the recursive serializer Hibernate uses to turn mapped values into JSON for aggregate (jsonb/OSON) mappings. It handles exactly three shapes: EntityMappingType (serialized as its identifier only), ManagedMappingType (embeddables flattened to a JSON object), and BasicType (scalars, or ArrayJdbcType plurals via visitBasicPluralValues/visitPluralAggregateValues). Any other MappingType implementation falls through to an UnsupportedOperationException naming the mapping type class - Hibernate has no JSON representation for it.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/spi/JsonGeneratingVisitor.java:185

							elementJdbcType,
							domainValue,
							options,
							writer
					);
				}
				writer.endArray();
			}
			else {
				writer.serializeJsonValue(
						basicType.convertToRelationalValue( value ),
						basicType.getJdbcJavaType(),
						basicType.getJdbcType(),
						options
				);
			}
		}
		else {
			throw new UnsupportedOperationException(
					"Support for mapping type not yet implemented: " + mappedType.getClass().getName()
			);
		}
	}

	/**
	 * Checks the provided {@code value} is either null or a lazy property.
	 *
	 * @param value the value to check
	 * @param writer the current {@link JsonDocumentWriter}
	 * @return {@code true} if it was, indicating no further processing of the value is needed, {@code false otherwise}.
	 */
	protected boolean handleNullOrLazy(Object value, JsonDocumentWriter writer) {
		if ( value == null ) {
			writer.nullValue();
			return true;
		}
		else {

View on GitHub (pinned to fad1729dce)

Solutions

  1. Map the offending attribute as a basic type (String plus an AttributeConverter) so visit() takes the BasicType branch
  2. Restructure the aggregate so it contains only basic and embeddable parts
  3. Upgrade Hibernate ORM - visitor coverage grows between releases
  4. If you own the extension, subclass JsonGeneratingVisitor (protected constructor, replaceable INSTANCE) or report the mapping type class in a Hibernate JIRA issue

Example fix

// before
@Embedded
@JdbcTypeCode(SqlTypes.JSON)
private MyAgg data; // MyAgg contains an attribute with a custom MappingType

// after: serialize the exotic part as a basic String
@Embeddable
class MyAgg {
    @JdbcTypeCode(SqlTypes.VARCHAR)
    private String exoticPart; // custom MappingType replaced by converter-backed String
}
Defensive patterns

Strategy: validation

Validate before calling

// Build-time smoke test: persist a sample of every JSON-aggregate-mapped entity
try (Session s = sessionFactory.openSession()) {
    Transaction tx = s.beginTransaction();
    for (Class<?> e : jsonMappedEntities) { s.persist(sampleOf(e)); s.flush(); }
    tx.rollback();
} // UnsupportedOperationException('Support for mapping type') fails the build, not production

Prevention

When it happens

Trigger: A JSON aggregate attribute whose sub-part exposes a MappingType that is none of the three handled shapes - e.g. a custom MappingType/ValuedModelPart contributed by an integration, or a mapping kind introduced by a newer Hibernate version that this visitor build has not learned, reached via serializeModelPart -> modelPart.getMappedType().

Common situations: Third-party or in-house extensions of Hibernate's runtime mapping model; incubating JSON aggregate features across version upgrades; unusual identifier or special-purpose mappings routed through the visitor during aggregate writes.

Related errors


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/a5db0f83794cd6ff. Report an issue: GitHub.