Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

mapping problem

 
Ranch Hand
Posts: 85
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using hibernate for my project.
so when i run project its giving error massage like this


org.hibernate.hql.ast.QuerySyntaxException: useraccount is not mapped [from useraccount a where a.User_UserID like 'u%']






i am using hibernate annotation. when i insert data into database its run without errors.for insert i used session.save() method.but i wrote hql query to get data from database.when i run project it's giving error as above.

this is my Login.java class that used to map database table.


can any one post comment to solve this error.
thanks
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't have a mapped entity called useraccount, you have one called Login.
 
pradeep gamage
Ranch Hand
Posts: 85
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
useraccount is table name. Login is class that map with useraccount.
Mr.Paul Sturrock can you give example code that i can use for retrieve data from database by using hibernate.

thanks.
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


useraccount is table name. Login is class that map with useraccount.



The exception tells me you are using this as your HQL query:


useraccount is the table, not the object. HQL works with objects.

There are quite a lot of examples in the Hibernate documentation if you need them.
 
pradeep gamage
Ranch Hand
Posts: 85
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am going to create Login.
so I have to get username and password from useraccount table.

this is class that map with useracount table


and i used following code fragment to take data from database table called useraccount.


when i run this it gives above mention error.



useraccountTable.jpg
[Thumbnail for useraccountTable.jpg]
useraccount table
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are still trying to query an unmapped entity, for the reason I mentioned above. Remember in Hibernate you are not using SQL.

I think its probably worth spending a few hours reading the documentation.
 
pradeep gamage
Ranch Hand
Posts: 85
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for replaying.
but i am not using sql. i am using hql
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indeed. So if you use HQL you need to query the mapped class, not the table. You have a mapped class called Login.

(and if you are not intending to use SQL, why define your variable contain the query as SQL_QUERY?)
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic