Hello All,
I'm making good use of the enum handling that is available in OpenJPA, which is
a very welcome advance over the persistence framework I was using last.
I see that I can configure my mappings to use either EnumType.ORDINAL or STRING
and I'm a little concerned that this is slightly restrictive, since the use of
ORDINAL more or less compels me to keep my database data inline with my code,
which may not be possible.
On the one hand, a probable irritant would be that inexperienced developers may
add elements to the enum and mess up any existing data in the DB - presumably
this would be easy to catch though.
On the other hand, there might be a need to code enums to fit existing data and
that could require large numbers of unused elements as padding - which would not
be too good.
Is this configuration option part of the EJB3 standard?
I would prefer to code my enums to use the database values:
public enum CodeType
{
NOT_USED(0),
SYSTEM(1),
FUNCTION(2);
private int dbValue;
CodeType(int newValue) { this.dbValue = newValue; }
public int toInteger() { return this.dbValue; }
}
Is there any plan for the future to incorporate this EnumType configuration?
Also, I have been searching the OpenJPA code base to ascertain how OpenJPA
recognises an enum when mapping data to such a field. I can't find the code -
could someone point me to it or give me a hint?
Thanks
Adam
|