• 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

mapping problem

 
Ranch Hand
Posts: 85
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?)
 
I’m tired of walking, and will rest for a minute and grow some wheels. This is the promise of this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic