{"record":{"id":"531a851097947b7e","repo":"hibernate/hibernate-orm","slug":"given-class-is-not-an-entity","errorCode":null,"errorMessage":"Given class is not an entity: {}","messagePattern":"Given class is not an entity: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/JpaMetamodelImpl.java","lineNumber":429,"sourceCode":"\t@Override\n\tpublic void addNamedEntityGraph(String graphName, RootGraphImplementor<?> rootGraph) {\n\t\tfinal var old = entityGraphMap.put( graphName, rootGraph.makeCopy( false, graphName ) );\n\t\tif ( old != null ) {\n\t\t\tCORE_LOGGER.tracef( \"EntityGraph named '%s' was replaced\", graphName );\n\t\t}\n\t}\n\n\t@Override\n\tpublic RootGraphImplementor<?> findEntityGraphByName(String name) {\n\t\treturn entityGraphMap.get( name );\n\t}\n\n\t@Override\n\tpublic <T> List<EntityGraph<? super T>> findEntityGraphsByJavaType(Class<T> entityClass) {\n\t\tfinal var entityType = entity( entityClass );\n\t\t//noinspection ConstantValue\n\t\tif ( entityType == null ) {\n\t\t\tthrow new IllegalArgumentException( \"Given class is not an entity: \" + entityClass.getName() );\n\t\t}\n\t\tfinal List<EntityGraph<? super T>> results = new ArrayList<>();\n\t\tfor ( var entityGraph : entityGraphMap.values() ) {\n\t\t\tif ( entityGraph.appliesTo( entityType ) ) {\n\t\t\t\t@SuppressWarnings(\"unchecked\") // safe, we just checked\n\t\t\t\tvar result = (RootGraphImplementor<? super T>) entityGraph;\n\t\t\t\tresults.add( result );\n\t\t\t}\n\t\t}\n\t\treturn results;\n\t}\n\n\t@Override\n\tpublic <T> Map<String, EntityGraph<? extends T>> getNamedEntityGraphs(Class<T> entityClass) {\n\t\tfinal var entityType = entity( entityClass );\n\t\t//noinspection ConstantValue\n\t\tif ( entityType == null ) {\n\t\t\tthrow new IllegalArgumentException( \"Given class is not an entity: \" + entityClass.getName() );","sourceCodeStart":411,"sourceCodeEnd":447,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/JpaMetamodelImpl.java#L411-L447","documentation":"Error \"Given class is not an entity: {}\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown when an operation requiring an entity type is given a class that is not a mapped entity.","commonSituations":"See trigger scenarios.","solutions":["Pass a class annotated @Entity that is managed by this persistence unit."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}