File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Hibernate Error : org.hibernate.MappingException: Unknown entity Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate Error : org.hibernate.MappingException: Unknown entity" Watch "Hibernate Error : org.hibernate.MappingException: Unknown entity" New topic

Hibernate Error : org.hibernate.MappingException: Unknown entity

Sanghamitra Parida

Joined: Nov 08, 2012
Posts: 1

Hello Experts,

I am new to hibernate. I am getting the below error:

org.hibernate.MappingException: Unknown entity: secDemo.Publisher
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(
at org.hibernate.impl.SessionImpl.getEntityPersister(
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(
at secDemo.FirstHibernateProgram.main(

My code goes here:

The main class code:

Could you please kind enough to tell me where I am going wrong?

Bill Gorder

Joined: Mar 07, 2010
Posts: 1682

You need to specify your entities somewhere you can either add a <mapping class= to your hibernate.cfg.xml or add them using AnnotationConfiguration()

Read section 1.2

[How To Ask Questions][Read before you PM me]
Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1283

I am having same issue.. and tried all solution mentioned over here.... but it still not working

Kaustubh G Sharma wrote:
Hello I tried to run a hibernate 2 example but getting org.hibernate.MappingException: Unknown entity: ... Please help. Can see my code below

No Kaustubh No Fun, Know Kaustubh Know Fun..
I agree. Here's the link:
subject: Hibernate Error : org.hibernate.MappingException: Unknown entity
jQuery in Action, 3rd edition