• 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

org.hibernate.hql.ast.QuerySyntaxException: UserEntity is not mapped

 
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have created a project with Spring and Hibernate.
It tries to read from the table...
But I am getting the following exception


org.hibernate.hql.ast.QuerySyntaxException: UserEntity is not mapped [from UserEntity]






I am trying to read from table using following code




Though I found on net that I need to use class name and not table name after the from word. But.........I am using class name, still I am getting the same exception...

Can someone please help me out...

You can see the complete project at the following link, if you want to see...

https://docs.google.com/file/d/0B5JlCbk20iFEUnZoMXR0YlV1bUk/edit?usp=sharing

I am new to spring and hibernate, please see if someone can exactly pin point the problem.

Do it during your leisure time...
 
Ranch Hand
Posts: 257
Hibernate Oracle Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Yogesh,

Seeing your code on very high level, It looks like you are trying to use spring and hibernate both together but not the way we use it via spring-orm.

You have created entity i.e. UserEntity and hibernate configuration file hibernate.cfg.xml, But not mentioned in hibernate.cfg.xml file that UserEntity entity mapping is for the session factory that you are creating.
This declaration can be done using mapping tag which is a child of session-factory tag in hibernate.cfg.xml. The sample use is as following -



Try it and let us know if you still face the same problem.
 
Yogesh Gandhi
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Salil Vverma wrote:Hey Yogesh,

Seeing your code on very high level, It looks like you are trying to use spring and hibernate both together but not the way we use it via spring-orm.

You have created entity i.e. UserEntity and hibernate configuration file hibernate.cfg.xml, But not mentioned in hibernate.cfg.xml file that UserEntity entity mapping is for the session factory that you are creating.
This declaration can be done using mapping tag which is a child of session-factory tag in hibernate.cfg.xml. The sample use is as following -



Try it and let us know if you still face the same problem.



Thanks Salil for your reply...
Apologies for replying late, actually i was out of station.

After putting in the said line in hibernate.cfg.xml, i am getting null pointer exception on the line









user-servlet.xml




hibernate.cfg.xml



 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic