hibernate/hibernate-orm · error · IllegalArgumentException

Could not resolve entity name for class '{object.getClass()}

Error message

Could not resolve entity name for class '{object.getClass()}'

What it means

Error "Could not resolve entity name for class '{object.getClass()}'" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java:1719

				return false;
			}
			else {
				return !entry.getStatus().isDeletedOrGone();
			}
		}
		catch ( MappingException e ) {
			throw new IllegalArgumentException( e.getMessage(), e );
		}
		catch ( RuntimeException e ) {
			throw getExceptionConverter().convert( e );
		}
	}

	private void assertInstanceOfEntityType(Object object) {
		try {
			final String entityName = getEntityNameResolver().resolveEntityName( object );
			if ( entityName == null ) {
				throw new IllegalArgumentException( "Could not resolve entity name for class '"
													+ object.getClass() + "'" );
			}
			else {
				requireEntityPersister( entityName );
			}
		}
		catch ( HibernateException e ) {
			throw new IllegalArgumentException( "Class '" + object.getClass()
												+ "' is not an entity class", e );
		}
	}

	@Override
	@Deprecated(forRemoval = true)
	@SuppressWarnings("removal")
	public boolean contains(@Nonnull String entityName, @Nonnull Object object) {
		return contains( object );
	}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Ensure the class is a mapped entity: annotate it with @Entity or map it in orm.xml/hibernate mappings, and include it in the persistence unit / annotated classes.
  2. Use session.getEntityName(entity) or the entity name string if the class itself is not registered.

When it happens

Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java:1719 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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