This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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

 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • 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
  • 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: 226
  • Mark post as helpful
  • send pies
  • 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



 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!