I use the Spring framework in my project, I stuck with the identification of DTO to be saved. I have a @RestController PUT-method end-point. I need to implement the logic: if an entity exists than override at DB else create a new one. So if the client will submit DTO 2 times it will 2 duplicated DTOs at DB. The only option I see to identify by ID(Actually, it how Spring Data operates out-of-the-box if id exists then override values of the entity). However, how can I hide this id from the client? Thanks.
P.S: Create a UNIQUE index for all fields and compare DTO by all fields is NOT the solution in my case. Many thanks.