• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hibernate Entity Mapping Problem

 
Greenhorn
Posts: 4
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Eclipse IDE Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Help Help

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 93
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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" />
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thankx a ton... a got the answer...my package name was conflicting...
 
reply
    Bookmark Topic Watch Topic
  • New Topic