Hello dear community,
We have a MERGE INTO
query like this:
WITH UpdatedPrices AS (
...
)
MERGE INTO Prices AS Target
USING UpdatedPrices AS Source
ON (Target.price_id = Source.price_id)
WHEN MATCHED THEN
UPDATE SET
Target.customer_id = Source.customer_id,
Target.status = Source.status
WHEN NOT MATCHED THEN
INSERT (price_id, customer_id, status)
VALUES (Source.price_id, Source.customer_id, Source.status);
UpdatedPrices
returns millions of records (so, loading all those records into java memory and processing via StatelessSession.upsert
, unfortunately, is not an option for us).
Is there a way to write this query via Criteria API? Insert select on conflict
is available in the latest hibernate version, but we’d like to use MERGE INTO
instead.
Thanks in advance.