On Thu, Dec 17, 2009 at 2:33 PM, KARR, DAVID (ATTCINW) <[email protected]>wrote:
> I'm trying to map a field that is essentially an enumerated type. The > ordinal values are stored in the DB. I can specify > "@Enumerated(EnumType.ORDINAL)" on the field, and then in the definition > of my Java enumerated type, I can define the possible values I can > expect. What seems to be missing here is that I have to map specific > ordinal values. I can't just assume the first value maps to "0", and so > on. I don't see an obvious way to define an enumerated type where I can > set the ordinal values. Am I missing something simple here? > Pro JPA 2 page 79-80 states: "There is currently no support within the JPA for mapping state contained within enumerated values. Neither is there support for the compromise position between STRING and ORDINAL of explicitly mapping each enumerated value to a dedicated numeric value different from its compiler-assigned ordinal value." I use a MyEnumLookup (a regular entity) to go with MyEnum (an enum). MyEnum has a state field that is the dedicated value. MyEnumLookup is in the database and I have a convenience method to convert them. I don't really like the solution but it works. I do like to have all the enum values in the database so I can have real foreign keys so I don't accidently get a bogus value. -- Daryl Stultz _____________________________________ 6 Degrees Software and Consulting, Inc. http://www.6degrees.com mailto:[email protected]
