Rahul
Rahul

Reputation: 61

Getting error in joining tables using hibernate

I am trying to join multiple table using hibernate but its not working for me can someone please help me out. I tried Criteria that was not working then thought of using query even that is not working My code looks like

 final Session session = getSession();
 String query = "SELECT r.REFERRER_ID from REFERRAL_PAYMENT_INFO r, SIGNUP_REFERRAL s";
 Query q = session.createQuery(query);
 List list = q.list();

I am getting this error -

"Caused by: org.hibernate.hql.ast.QuerySyntaxException: 
 REFERRAL_PAYMENT_INFO is not mapped [SELECT r.REFERRER_ID from REFERRAL_PAYMENT_INFO 
 r, SIGNUP_REFERRAL s]"

Upvotes: 0

Views: 116

Answers (1)

Pablo
Pablo

Reputation: 3673

You must use the classes (entities) you mapped in HQL queries. If you want to use normal SQL, then you have to call session.createSQLQuery().

Look at the documentation for hibernate session:

http://docs.jboss.org/hibernate/orm/3.5/api/org/hibernate/Session.html

Upvotes: 1

Related Questions