# Requirement for Entity Classes in Hibernate 6.5

**URL:** <https://discourse.hibernate.org/t/requirement-for-entity-classes-in-hibernate-6-5/10049>\
**Category:** Hibernate ORM\
**Created:** [August 1, 2024, 6:18am UTC](https://discourse.hibernate.org/t/requirement-for-entity-classes-in-hibernate-6-5/10049 "2024-08-01T06:18:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kaushik\_LV](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/kaushik_lv/32/3312_2.png) [@Kaushik\_LV](https://discourse.hibernate.org/u/Kaushik_LV)\
**Post date:** [August 1, 2024, 6:18am UTC](https://discourse.hibernate.org/t/requirement-for-entity-classes-in-hibernate-6-5/10049/1 "2024-08-01T06:18:48Z")

</div>

Hi,  
We are trying to migrate to Hibernate 6.5 and have done the necessary code changes.  
We are currently still using the hbm.xml files itself and have not moved to annotated class files.

Here is the hbm.xml file currently being used -

```auto
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                                   "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
    <class entity-name="artist" lazy="true" name="orm.artist" table="ARTISTS">
        <id name="id" type="int">
            <column length="10" name="ARTISTID"/>
            <generator class="increment"/>
        </id>
        <property name="firstname" type="string">
            <column name="FIRSTNAME"/>
        </property>
        <property name="lastname" type="string">
            <column name="LASTNAME"/>
        </property>
    </class>
</hibernate-mapping>

```

We were trying to run a basic testcase where we are just trying to insert a new record to the table. But we are getting this exception right now -

```auto
org.hibernate.MappingException: entity class not found: orm.artist
	at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:179)
	at org.hibernate.jpa.event.internal.CallbacksFactory.buildCallbackRegistry(CallbacksFactory.java:48)
	at org.hibernate.event.spi.EventEngine.<init>(EventEngine.java:44)
	at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
	at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:457)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:997)

```

If we run the same exact code using the older version of Hibernate (5.6.15) then its working and we dont see any errors.

Looking at the exception, it looks like there is an expectation for an entity class file but we are not using those right now. Is it mandatory to be using them with Hibernate 6 ?  
If not , is there a setting to be enabled which can bypass this requirement?

---

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [August 1, 2024, 11:54am UTC](https://discourse.hibernate.org/t/requirement-for-entity-classes-in-hibernate-6-5/10049/2 "2024-08-01T11:54:28Z")

</div>

I don’t know what ORM 5 did with the `name` attribute value of the `class` tag, but that name represents the class name, so setting it tells Hibernate to use that class. If you want to interact with the entity through that name, you will have to set the `entity-name` attribute to that value.

---

<div class="post-metadata">

**Author:** ![Kaushik\_LV](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/kaushik_lv/32/3312_2.png) [@Kaushik\_LV](https://discourse.hibernate.org/u/Kaushik_LV)\
**Post date:** [August 5, 2024, 2:49am UTC](https://discourse.hibernate.org/t/requirement-for-entity-classes-in-hibernate-6-5/10049/3 "2024-08-05T02:49:28Z")

</div>

Hi @beikov

I have tried to set that same value to the `entity-name` attribute as well but that didnt work. So I went ahead and created a testcase using the testcase templates which you provide. Hope this will give you the clarity on what’s exactly going on.

I have created a testcase with the way that we are currently initializing the settings and building the SessionFactory. I have also created the EntityManagerFactory using the same SessionFactory. I have placed the hbm.xml file that we are using as well in the resources folder.

Here is the link to my drive containing the project -  
[https://drive.google.com/drive/folders/175HQFIWSkj7LKJzX0HZKntMJlFEeo-qf?usp=sharing](https://drive.google.com/drive/folders/175HQFIWSkj7LKJzX0HZKntMJlFEeo-qf?usp=sharing)

Please have a look and let me know if I am doing it the expected way itself.

---

<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:** [August 5, 2024, 7:24am UTC](https://discourse.hibernate.org/t/requirement-for-entity-classes-in-hibernate-6-5/10049/4 "2024-08-05T07:24:02Z")

</div>

Please create a new ticket in our [issue tracker](https://hibernate.atlassian.net/browse/HHH) and attach that reproducer as a `zip` file directly in the issue or at most link to a GitHub repository where we can look at the code.
