hibernate/hibernate-orm · error · MappingException

Unable to determine entity for fetch profile fetch

Error message

Unable to determine entity for fetch profile fetch [%s:%s]

What it means

Binding a <fetch-profile> whose <fetch> item names an entity that could not be resolved in the metadata being built. The entity attribute of the fetch declaration is typo'd or refers to an unmapped class.

Solutions

  1. Correct the entity attribute of the <fetch-profile/> <fetch> element so it names a mapped entity, and the association attribute on it.

Example fix

Correct the entity attribute of the <fetch-profile/> <fetch> element so it names a mapped entity, and the association attribute on it.
Defensive patterns

Strategy: validation

When it happens

Trigger: An hbm.xml / orm.xml mapping document violates a mapping rule during bootstrap.

Common situations: Legacy XML mappings with invalid combinations (column+formula, mixed inheritance, missing identifiers, bad extends references).


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

Appendix: source

Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/FetchProfileBinder.java:55


	/**
	 * Handling for a {@code <fetch-profile/>} declaration.
	 *
	 * @param context Access to information relative to the mapping document containing this binding
	 * @param fetchProfileBinding The {@code <fetch-profile/>} binding
	 * @param containingEntityName The name of the entity containing the fetch profile declaration.  May
	 * be {@code null} to indicate a fetch profile defined at the root.
	 */
	public static void processFetchProfile(
			HbmLocalMetadataBuildingContext context,
			JaxbHbmFetchProfileType fetchProfileBinding,
			String containingEntityName) {
		final var profile = fetchProfile( context, fetchProfileBinding );
		for ( var fetchBinding : fetchProfileBinding.getFetch() ) {
			final String entityName = entityName( containingEntityName, fetchBinding );
			if ( entityName == null ) {
				throw new MappingException(
						String.format(
								"Unable to determine entity for fetch profile fetch [%s:%s]",
								profile.getName(),
								fetchBinding.getAssociation()
						),
						context.getOrigin()
				);
			}
			profile.addFetch( new FetchProfile.Fetch(
					entityName,
					fetchBinding.getAssociation(),
					fetchMode( fetchBinding.getStyle().value() ),
					EAGER
			) );
		}
	}

	private static String entityName(String containingEntityName, JaxbHbmFetchProfileType.JaxbHbmFetch fetchBinding) {

View on GitHub (pinned to fad1729dce)