hibernate/hibernate-orm · error · IllegalArgumentException
Class '{object.getClass()}' is not an entity class
Error message
Class '{object.getClass()}' is not an entity class What it means
Error "Class '{object.getClass()}' is not an entity class" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java:1727
}
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 );
}
@Override
@Nonnull
public ProcedureCall createStoredProcedureCall(@Nonnull String procedureName) {
checkOpen();
// checkTransactionSynchStatus();
return super.createStoredProcedureCall( procedureName );
}View on GitHub (pinned to fad1729dce)
Solutions
- Mark the class as an entity (@Entity or XML mapping) and ensure it is scanned/registered with the SessionFactory before use.
- Pass an actual entity class or instance rather than a DTO, proxy base, or unmapped class.
When it happens
Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java:1727 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/160e195b15ba8b3c.
Report an issue: GitHub.