# "Not a managed type: …Entity" after hibernate 6 upgrade

**URL:** <https://discourse.hibernate.org/t/not-a-managed-type-entity-after-hibernate-6-upgrade/9798>\
**Category:** Hibernate ORM\
**Created:** [June 24, 2024, 1:13pm UTC](https://discourse.hibernate.org/t/not-a-managed-type-entity-after-hibernate-6-upgrade/9798 "2024-06-24T13:13:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alfonz19](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/alfonz19/32/2440_2.png) [@alfonz19](https://discourse.hibernate.org/u/alfonz19)\
**Post date:** [June 24, 2024, 1:13pm UTC](https://discourse.hibernate.org/t/not-a-managed-type-entity-after-hibernate-6-upgrade/9798/1 "2024-06-24T13:13:13Z")

</div>

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:

```auto
<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?

---

<div class="post-metadata">

**Author:** ![mbladel](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/mbladel/32/2128_2.png) [@mbladel](https://discourse.hibernate.org/u/mbladel)\
**Post date:** [June 25, 2024, 6:49am UTC](https://discourse.hibernate.org/t/not-a-managed-type-entity-after-hibernate-6-upgrade/9798/2 "2024-06-25T06:49:48Z")

</div>

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](https://docs.jboss.org/hibernate/orm/current/userguide/html_single/Hibernate_User_Guide.html#settings-persistence) `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`?

---

<div class="post-metadata">

**Author:** ![alfonz19](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/alfonz19/32/2440_2.png) [@alfonz19](https://discourse.hibernate.org/u/alfonz19)\
**Post date:** [June 25, 2024, 10:39am UTC](https://discourse.hibernate.org/t/not-a-managed-type-entity-after-hibernate-6-upgrade/9798/3 "2024-06-25T10:39:44Z")

</div>

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.?
