Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Yogesh Gandhi
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...
 
Salil Vverma
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



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic