I have Enum class - Status with three values: GREEN, YELLOW, RED
I also have an entity SomeThing with a field of Status type. It has @Enumerated(EnumType.STRING) annotation.
In my DAO with Hibernate criteria I would like to sort through SomeThing items ordered by Status, but the default order by method is alphabetical (because of EnumType.STRING), so I would get GREEN items first, then RED ones and finally YELLOW ones.
But I would like to create a custom order by method. I would like to get RED items first, then GREEN, then YELLOW.
The first idea was to create a dictionary table with Status field and and int orderIndex field with OneToMany relationship (one Status type, many SomeThing records) with SomeThing entity. Then I could assign int values to different Status types and then order it by orderIndex field.
What would be the best way to achieve what I need? Thanks in advance for all your help and input.