I would like to perform a batch upgrade with JPA and Postgres. I cannot use merging, as I am checking the conflict on a unique Constraint that is not PK. I found that for updating in postgres we can now use ON Conflict functionality. So basically I would like to execute my own query execution in JPA . The request will look like this:
INSERT INTO user (user_id, display_name ) VALUES('1', 'sg27') ON CONFLICT (user_id) DO UPDATE SET display_name = 'sg27' RETURNING *;
I will loop over the list of objects and make a query.
So, my question is when the inline insert of the request, we can use manual cleaning, for example em.flush() . Will it work for batch insertion.
If not, then someone please tell me what are the possible solutions to this problem?
Thank you for your time.
postgresql hibernate jpa upsert
Saikat ganguly
source share