How to handle choice field with JPA 2, Hibernate 3.5
- by phmr
I have an entity with Integer attributes that looks like this in proto code:
class MyEntity:
String name
Integer frequency
Integer type
def getFrequency()
def getType()
get* accessors return strings according to this table.
value(type) HumanReadableString(type)
1 BSD
2 Apache
3 GPL
min frequency max frequency HumanReadableString(frequency)
0 1000 rare
1000 2000 frequent
2001 3000 sexy
It should be possible to get all possible values that an attribute can take, example:
getChoices(MyEntity, "type") returns ("rare", "frequent", "sexy")
It should be possible to get the bound value from the string:
getValue(MyEntity, "frequency", "sexy") returns (2000,3000)