hibernate/hibernate-orm · error · PathException

Could not resolve attribute '%s' of '%s' due to the attribut

Error message

Could not resolve attribute '%s' of '%s' due to the attribute being declared in multiple subtypes '%s' and '%s'

What it means

Error "Could not resolve attribute '%s' of '%s' due to the attribute being declared in multiple subtypes '%s' and '%s'" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/EntityTypeImpl.java:239

				return hasSingleIdAttribute() ? findIdAttribute() : getIdentifierDescriptor();
			}
			else if ( EntityDiscriminatorMapping.matchesRoleName( name ) ) {
				return discriminatorPathSource;
			}
			else {
				return null;
			}
		}
	}

	private SqmPersistentAttribute<?, ?> findSubtypeAttribute(String name) {
		SqmPersistentAttribute<?,?> subtypeAttribute = null;
		for ( var subtype : super.getSubTypes() ) {
			final var candidate = subtype.findSubTypesAttribute( name );
			if ( candidate != null ) {
				if ( subtypeAttribute != null
						&& !isCompatible( subtypeAttribute, candidate, metamodel.getMappingMetamodel() ) ) {
					throw new PathException(
							String.format(
									Locale.ROOT,
									"Could not resolve attribute '%s' of '%s' due to the attribute being declared in multiple subtypes '%s' and '%s'",
									name,
									getTypeName(),
									subtypeAttribute.getDeclaringType().getTypeName(),
									candidate.getDeclaringType().getTypeName()
							)
					);
				}
				subtypeAttribute = candidate;
			}
		}
		return subtypeAttribute;
	}

	@Override
	public @Nullable SqmPersistentAttribute<? super J, ?> findAttribute(@Nonnull String name) {

View on GitHub (pinned to fad1729dce)

Solutions

  1. Qualify the query path with a treat() to the specific subtype declaring the attribute.
  2. Rename one of the conflicting subtype attributes to make the attribute unambiguous.

When it happens

Trigger: Thrown when an attribute name is ambiguous because it is declared in two different subtypes of the queried entity hierarchy.

Common situations: See trigger scenarios.


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