• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate Entity Mapping Problem

 
Prashant kr Sinha
Greenhorn
Posts: 4
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting this error frequently... !! can you all guys help me

Exception in thread "main" org.hibernate.MappingException: Unknown entity: com.hibernate.User
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:693)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:92)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:1005)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:998)
at com.hibernate.UserData.main(UserData.java:24)

User


UserData



hibernAte.cfg.xml
 
Prashant kr Sinha
Greenhorn
Posts: 4
Chrome Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Help Help
 
Connor Van Elswyk
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post your SQL so we can see how your table is designed. Beyond that, the snippet doesn't make a ton of sense. The object is never persisted but even if it was, your redefining it three times?
 
Tim Nachreiner
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you need to add an element like this to your hibernate.cfg.xml file.

<mapping class="<package name>.User" />
 
Tim Holloway
Saloon Keeper
Posts: 18367
56
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Nachreiner wrote:I think you need to add an element like this to your hibernate.cfg.xml file.

<mapping class="<package name>.User" />


Or in this particular case, it would be:


But "com.hibernate" is a very bad choice for a user-defined package name. It conflicts with the real com.hibernate package.


There's a way to auto-scan mapping classes in Hibernate these days, but I don't remember the details.
 
Prashant kr Sinha
Greenhorn
Posts: 4
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankx a ton... a got the answer...my package name was conflicting...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic