How to update composite key respective values

Hello Cuba Team!!

I want to update composite key respective values, instead of creating the new record.
In my code I have Country, Year, Value, Name in test entity. In this I want to set Country and Year are composite key. While creating a record If I enter the same values as there in the database, then it should say “Same combination already exists”. If I change any of those values then it should update with the respective composite key.

Thank You!!