I have an entity like so:
@Entity
@Table(name = "MyTable", schema = "test")
@Getter @Setter
public class PurgeSystemsEntity {
@Id
@Column(name = "id", nullable = false)
private int id;
@Column(name = "system_name", nullable = false, length = 255)
private String systemName;
.
.
}
How do I validate that the string obtained from DB (like when doing a .findAll()) in systemName field is one of the possible options defined in the Enum System :
public static enum System {
PROD, DEV, QA;
}
So, If a row is fetched with systemName value being 'STAGING', it should throw an exception immediately.
Is there some elegant way to do this?