everyone. I have problem replacing existing rows in table with new ones. I use JPA and PostgreSQL DB. I'm trying to delete all existing rows and then create new ones, but receive exception: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "user_destination_pk". All these actions are inside single JTA transaction. It seems that JPA doesn't delete rows before inserting, but I receive no delete exception... Any help is appreciated.
Use the Hibernate Session.flush()
method to flush (execute the SQL of) the deletes before saving/adding the new entities.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With