Win a copy of AWS Security this week in the Cloud/Virtualization 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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

 
Ranch Hand
Posts: 233
  • 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: 233
  • 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



 
I found some pretty shells, some sea glass and this lovely tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic