According to the docs merge() "implements the semantics of an INSERT … ON DUPLICATE KEY UPDATE statement, which will update the row regardless of which (unique) key value is already present".
This doesn't seem to be the case. I have a unique key comprising of 2 fields and I'm getting an exception instead of the merge following through. This is with PostgreSQL:
"Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "some_unique_key"
Detail: Key (field1, field2)=(value1, value2) already exists."
Shouldn't record.merge() insert the missing record or update it if it already exists?