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.