0
votes

how to select records from multiple tables by using HQL Query..

    Session session=dao.getSessionFactory().openSession();

    Query query=session.createQuery("from b.Customer_name PurchaseDetailBean p,BookingBean b where p.Booking_Id=b.Booking_Id ");


    System.out.println("dlkkdc"+query);

    arg0.getPortletSession().setAttribute("query", query);

      Query q1 = (Query) arg0.getPortletSession().getAttribute("query");
      Gson gson = new Gson();


    System.out.println("***" + gson.toJson(q1.list()));
    arg0.getPortletSession().setAttribute("adminsales", gson.toJson(q1.list()));
    System.out.println("iiiiiiiiiiiiiiiiiiiiiiii"+gson.toJson(q1.list()));

ITZ showing error::

org.hibernate.hql.ast.QuerySyntaxException: unexpected token: p near line 1, column 41 [from b.Customer_name PurchaseDetailBean p,Com.bean.BookingBean b where p.Booking_Id=b.Booking_Id ]

1

1 Answers

0
votes

Selected column must be appear before from

So, change your Query from

Query query=session.createQuery
   ("from b.Customer_name PurchaseDetailBean p,BookingBean b where p.Booking_Id=b.Booking_Id ");

to

Query query=session.createQuery
   ("b.Customer_name from PurchaseDetailBean p,BookingBean b where p.Booking_Id=b.Booking_Id ");