hibernate/hibernate-orm · error · IllegalArgumentException

Expecting class: [%1$s], but containerJavaType is of type: [

Error message

Expecting class: [%1$s], but containerJavaType is of type: [%2$s] for propertyName: [%3$s]

What it means

Error "Expecting class: [%1$s], but containerJavaType is of type: [%2$s] for propertyName: [%3$s]" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/property/access/internal/PropertyAccessStrategyMapImpl.java:29

import jakarta.annotation.Nullable;

/**
 * @author Steve Ebersole
 * @author Gavin King
 */
public class PropertyAccessStrategyMapImpl implements PropertyAccessStrategy {
	/**
	 * Singleton access
	 */
	public static final PropertyAccessStrategy INSTANCE = new PropertyAccessStrategyMapImpl();

	@Override
	public PropertyAccess buildPropertyAccess(@Nullable Class<?> containerJavaType, String propertyName, boolean setterRequired) {

		// Sometimes containerJavaType is null, but if it isn't, make sure it's a Map.
		if (containerJavaType != null && !Map.class.isAssignableFrom( containerJavaType)) {
			throw new IllegalArgumentException(
				String.format(
					"Expecting class: [%1$s], but containerJavaType is of type: [%2$s] for propertyName: [%3$s]",
					Map.class.getName(),
					containerJavaType.getName(),
					propertyName
				)
			);
		}

		return new PropertyAccessMapImpl( this, propertyName );
	}
}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Use the map-based PropertyAccessStrategy only with Map-typed (dynamic-map) entities.
  2. Change the entity representation mode to POJO if a concrete class is used.

When it happens

Trigger: A runtime precondition of the Hibernate API is violated.

Common situations: Occurs when application code or configuration does not satisfy the documented contract of the API being called.


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