Requirement for Entity Classes in Hibernate 6.5

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 -

<!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 -

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?

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.

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

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

Please create a new ticket in our issue tracker 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.