1

I have created a simple hibernate application and getting the above-mentioned exception while running(I'm using hibernate 5.4.0.Final version). Everything works fine If I use version 4.3.5.Final but not with 5.4.0.Final

Tried How to get rid of 'java.lang.IllegalArgumentException: Unknown entity' while running a simple hibernate app?, it didn't help me.

hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
        <property name="connection.url">jdbc:oracle:thin:@192.168.0.998:1522:TEST</property>
        <property name="connection.username">test</property>
        <property name="connection.password">test</property>
        <property name="hbm2ddl.auto">update</property>
        <property name="show_sql">true</property>

        <mapping class="com.mahipal.model.WsdlMst"/>

    </session-factory>
</hibernate-configuration>

Trace:

Exception in thread "main"
java.lang.IllegalArgumentException: Unknown entity: com.mahipal.model.WsdlMst
    at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:807)
    at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:788)
    at com.mahipal.test.Test.main(Test.java:56)
Mahipal Reddy
  • 389
  • 6
  • 20

1 Answers1

0

Check The Hibernate configuration file which must define the entity classes:

For example

Or you must explicitly add the class to the configuration using

For example configuration.addClass(annotations.Users.class) Read mappings as a application resourceName addResource is for add hbml.xml files in case of declarative approach configuration.addResource("myFile.hbm.xml"); // not hibernateAnnotations.cfg.xml

Puneet
  • 11
  • 3