Unknown Entity exception with Java Hibernate

If you hit an exception as “Unknown Entity” with Java Hibernate as below:

org.hibernate.MappingException: Unknown entity: com.myapplication.mymodel.modelname.ModalClass

It means the Class is not added into Hibernate configuration and to solve it simply you would need to add the class into your hibernate.cfg.xml as below:

  • <session-factory>
    • ……
    • <mapping class=”com.myapplication.mymodel.modelname.ModalClass” />
  • </session-factory>

You can find more details at StackOverflow.

Keywords: Java, Hibernate, Class, Unknown Entity, Exception


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s