hibernate/hibernate-orm · error · UnsupportedOperationException

Support for defining a NativeQuery attribute result based…

Error message

Support for defining a NativeQuery attribute result based on a composite path is not yet implemented

What it means

Limitation guard in Builders.attributeResult: the native-query attribute result was specified with a dotted (composite) attribute path, which the mapping builder does not yet implement.

Solutions

  1. Native query attribute results on composite paths are not implemented. Map the composite columns individually.
Defensive patterns

Strategy: fallback

When it happens

Trigger: A code path that Hibernate has not implemented is exercised: Support for defining a NativeQuery attribute result based on a composite path is not yet implemented

Common situations: Using newer/edge API features (certain projections, specifications, fetch mementos, composite-path native mappings, null keys in key-based pagination) that are present but not yet implemented.


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

Appendix: source

Thrown at hibernate-core/src/main/java/org/hibernate/query/results/internal/Builders.java:153

	public static ResultBuilderBasicValued scalar(int position, BasicType<?> type) {
		// will be needed for interpreting legacy HBM <resultset/> mappings
		return new DynamicResultBuilderBasicStandard( position, type );
	}

	public static <J> DynamicResultBuilderInstantiation<J> instantiation(Class<J> targetJavaType, SessionFactoryImplementor factory) {
		final var targetJtd =
				factory.getTypeConfiguration().getJavaTypeRegistry()
						.resolveDescriptor( targetJavaType );
		return new DynamicResultBuilderInstantiation<>( targetJtd );
	}

	public static ResultBuilder attributeResult(
			String columnAlias,
			String entityName,
			String attributePath,
			SessionFactoryImplementor sessionFactory) {
		if ( attributePath.contains( "." ) ) {
			throw new UnsupportedOperationException(
					"Support for defining a NativeQuery attribute result based on a composite path is not yet implemented"
			);
		}

		final MappingMetamodelImplementor mappingMetamodel = sessionFactory.getMappingMetamodel();
		final String fullEntityName = mappingMetamodel.getImportedName( entityName );
		final EntityPersister entityMapping = mappingMetamodel.findEntityDescriptor( fullEntityName );
		if ( entityMapping == null ) {
			throw new IllegalArgumentException( "Could not locate entity mapping : " + fullEntityName );
		}

		final AttributeMapping attributeMapping = entityMapping.findAttributeMapping( attributePath );
		if ( attributeMapping == null ) {
			throw new IllegalArgumentException( "Could not locate attribute mapping : " + fullEntityName + "." + attributePath );
		}

		if ( attributeMapping instanceof SingularAttributeMapping singularAttributeMapping ) {
			return new DynamicResultBuilderAttribute( singularAttributeMapping, columnAlias, fullEntityName, attributePath );

View on GitHub (pinned to fad1729dce)