I want to create an entity containing 2 fields that need to be unique in together. One of the fields is a Boolean:
@Entity
public class SoldToCountry {
private String countryId;
private Boolean isInt;
}
For a given String there should never exist more than 2 entries one with isInt:true
and the other isInt:false
.
I read the doc about @Id but it seems that Boolean is not supported. For me it would also be ok to have a unique constraint spanned over both fields and using a generated id.
What is the best way to get this constraint via JPA?