aspose file tools*
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
Author

Hibernate Error : org.hibernate.MappingException: Unknown entity

Sanghamitra Parida
Greenhorn

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

Joined: Mar 07, 2010
Posts: 1649
    
    7

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


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

Joined: May 13, 2010
Posts: 1270

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




















No Kaustubh No Fun, Know Kaustubh Know Fun..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate Error : org.hibernate.MappingException: Unknown entity