within our domain/entity object we have an enum field, but the enum value is stored as a string in db
@Column(name = "priority")
@Enumerated(EnumType.STRING)
public Priority getPriority() {
return priority;
}
so when we try to order by this field with jpa findall method
order by
priority
in can only order it alphabetically! However we need to assign order to the various values there.
public enum Priority {
Critical,
Major,
Minor,
Informational
}
Is there anyway to define an order here that jpa will follow when ordering/sorting?