I am trying to write a query for insert with select. but i am getting this error Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: order near line 11, column 23
Query query = hibSession.createQuery("""
INSERT INTO
ProcessOrder(
version,
numberOfPeriods,
billingPeriodStart,
billingPeriodEnd,
invoice,
billingRun,
org,
order)
SELECT
1L AS version,
1 AS numberOfPeriods,
ilt.billingStartDate AS billingPeriodStart,
ilt.billingEndDate AS billingPeriodEnd,
i AS invoice,
i.billingRun as billingRun,
i.org as org,
soi as order
from
Invoice as i
join i.ordersIncluded as soi
join i.invoiceLineItems as ilt
where
i.billingRun = 36 AND
i.status IN ('Outstanding','Paid') AND
ilt.position = 1 """)
Please help to overcome this problem