I have a problem like this. The "name" and "lastname" fields are not unique individually. But name + lastname I want to be unique. So the same "name" can be more than one, or the same "lastname" can be more than one, but I want to have just one "name + lastname".
For example:
Registered in the database:
Name: "Erdem" lastName: "ÖZDEMİR"
Name: "Erdem" lastName: "AYDEMİR"
When I want to record the above record, I want it to
record successfully
Name: "Ahmet" lastName: "ÖZDEMİR"
When I want to record the above record, I want it to
record successfully
Name: "Erdem" lastName: "ÖZDEMİR"
But since it's the same name and lastname here,
give me an error!
How can it be done? How can a solution be created in the entity? My problem is a little ridiculous, but I need to take care of it.
Contact.java
@Document(collection = "contact")
public class Contact implements Serializable {
@Id
private String id;
private String name;
private String lastName;
private List<String> phones;
//get & set
}