You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently JDO and JPA allow persisting as "name()" (String) or "ordinal()" (Integer) of the Enum. DataNucleus (RDBMS) allows control over the ordinal value to be persisted, like this
public enum MyColour
{
RED((short)1), GREEN((short)3), BLUE((short)5), YELLOW((short)8);
private short value;
private MyColour(short value)
{
this.value = value;
}
public short getValue()
{
return value;
}
public static MyColour getEnumByValue(short value)
{
switch (value)
{
case 1:
return RED;
case 3:
return GREEN;
case 5:
return BLUE;
default:
return YELLOW;
}
}
}
Currently JDO and JPA allow persisting as "name()" (String) or "ordinal()" (Integer) of the Enum. DataNucleus (RDBMS) allows control over the ordinal value to be persisted, like this
Maybe we would benefit from allowing control over either ordinal or name, so we could have
or something similar? Additionally it should be made available for ALL datastores not just RDBMS.
The text was updated successfully, but these errors were encountered: