-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: QuerySyntaxException: unexpected token: join near line 1
PostPosted: Thu Oct 26, 2017 3:22 am 
Newbie

Joined: Thu Oct 26, 2017 12:15 am
Posts: 1
I am getting this exception please resolve

Code:
org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: join near line 1, column 801 [Select ubi.name,uoi.user_order_id,uoi.train_no,uoi.date, COALESCE(voi.gstin,0,1,2)as gstin,voi.assignee_person_name as vendor_name,voi.vendor_id,COALESCE(voi.hsn_code,0,1,2) as hsn_code,COALESCE(voi.gst_percent,0,1,2) as gst_percent, uom.quantity,uom.itemCustomerPayable,uom.itemBasePrice,uoi.discount,uoi.delivery_cost,uoi.totalCustomerPayableCapped,uoi.totalCapped,uoi.order_outlet_id,COALESCE(uom.cgstPercent,0,1,2) as cgst_percent, COALESCE(uom.itemVendorGstPercent,0,1,2) as igst_percent,COALESCE(uom.sgstPercent,0,1,2) as sgst_percent,COALESCE(uom.cgstAmount,0,1,2) as cgst_amount,COALESCE(uom.sgstAmount,0,1,2) as sgst_amount,COALESCE(uom.igstAmount,0,1,2) as igst_amount, mm.menu_name from com.tk.model.UserOrderInfo uoi  join uoi.vendorOutletInfo voi where uoi.order_outlet_id=voi.outlet_id join uoi.userOrderMenu uom where uom.userOrderId=uoi.user_order_id  and uom.menuRevisionId=uoi.menu_revision_id join MasterMenu mm where mm.menu_id=uom.itemId join uoi.userBasicInfo ubi where ubi.user_id=uoi.user_id where uoi.user_order_id =:orderId and uoi.is_undeliver=0 and uoi.is_cancel=0  and uoi.is_send=1]


Top
 Profile  
 
 Post subject: Re: QuerySyntaxException: unexpected token: join near line 1
PostPosted: Thu Oct 26, 2017 3:31 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1638
Location: Romania
It's much better if you format the SQL query, with a tool like sqlformat.org:

Code:
SELECT ubi.name,
       uoi.user_order_id,
       uoi.train_no,
       uoi.date,
       COALESCE(voi.gstin,0,1,2)AS gstin,
       voi.assignee_person_name AS vendor_name,
       voi.vendor_id,
       COALESCE(voi.hsn_code,0,1,2) AS hsn_code,
       COALESCE(voi.gst_percent,0,1,2) AS gst_percent,
       uom.quantity,
       uom.itemCustomerPayable,
       uom.itemBasePrice,
       uoi.discount,
       uoi.delivery_cost,
       uoi.totalCustomerPayableCapped,
       uoi.totalCapped,
       uoi.order_outlet_id,
       COALESCE(uom.cgstPercent,0,1,2) AS cgst_percent,
       COALESCE(uom.itemVendorGstPercent,0,1,2) AS igst_percent,
       COALESCE(uom.sgstPercent,0,1,2) AS sgst_percent,
       COALESCE(uom.cgstAmount,0,1,2) AS cgst_amount,
       COALESCE(uom.sgstAmount,0,1,2) AS sgst_amount,
       COALESCE(uom.igstAmount,0,1,2) AS igst_amount,
       mm.menu_name
FROM com.tk.model.UserOrderInfo uoi
JOIN uoi.vendorOutletInfo voi
WHERE uoi.order_outlet_id=voi.outlet_id
  JOIN uoi.userOrderMenu uom WHERE uom.userOrderId=uoi.user_order_id
  AND uom.menuRevisionId=uoi.menu_revision_id
  JOIN MasterMenu mm WHERE mm.menu_id=uom.itemId
  JOIN uoi.userBasicInfo ubi WHERE ubi.user_id=uoi.user_id WHERE uoi.user_order_id =:orderId
  AND uoi.is_undeliver=0
  AND uoi.is_cancel=0
  AND uoi.is_send=1


Now, it's quite obvious that the SQL query is malformed.

You can't use JOIN after a WHERE clause, then again a WHERE clause.

You need to revise the JPQL/HQL query you wrote so that it follows the SELECT query BNF.

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.