• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate Error : org.hibernate.MappingException: Unknown entity

 
Sanghamitra Parida
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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(SessionFactoryImpl.java:489)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1021)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:83)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:429)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:424)
at secDemo.FirstHibernateProgram.main(FirstHibernateProgram.java:29)

My code goes here:



The main class code:



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

Regards
Sasanka
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html/ch01.html#setup-configuration
 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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: com.training.HelloWorld ... Please help. Can see my code below


















 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic