I have a working project, which I’m upgrading to hibernate 6. Namely, all entities are discovered; basePackageClasses in @EnableJpaRepositories and @EntityScan are set correctly. I upgraded to:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
i.e. hibernate-core 6.5.2 Final, replaced all javax.persistence with jakarta.persistence etc. and I’m getting
Caused by: java.lang.IllegalArgumentException: Not a managed type: class my.package.entities.MyEntity
Any idea what could be causing this?
Hi, the two annotations you mention are defined by Spring, so this might not be the best place to ask regarding those. When Hibernate detects mapped classes, by default, it respects the persistence unit setting hibenate.archive.autodetecion
of your persistence.xml
file.
Other than that, looks like @EntityScan
is used to define a custom package where the @Entity
-annotated classes are found, so I suppose you’re setting that to my.package.entities
?
There is no neither persistence.xml in sources nor in any build target. No idea how this work to be honest.
You are probably correct, it’s springboot issue. I just created mwe and it really seems to be springboot problem, since mwe works. The project worked with springboot2/hibernate 5. I just upgraded to springboot3/hibernate6, entity not managed. I didn’t expect any meaning of @EntityScan etc. to change it’s meaning (namely if it’s not documented), everything seems correct, just this error is generated.
Is there a way how to turn on hibernate logging what is being scanned, what was discovered etc.?