only accept a set of values java bean class annotations code example Example: jpa validation string only number @Pattern(regexp="[\\d]{6}")