openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Krzysztof <>
Subject Re: Enum as a Key in a Map
Date Wed, 10 Dec 2008 18:25:35 GMT

Indeed, changing the map to be keyed on a plain type does not solve the
problem until the owning 'source' field becomes plain type too.


	private Map<Integer, TSImpl> tsMap;
	private TSType tsType; //stays as enum, same exception thrown
gives exactly same cast exception, but if we change this part of Id to int
it works. Also calling persist on root persists map elements properly.
//	@Enumerated(EnumType.ORDINAL)
//	private TSType tsType;
	private int tsType;

This is not really elegant and affects a lot of code. Could you please
suggest any workaround so enum could be used as a key and is compatible with
ObjectId? Annotating enum as Embeddable gives enhancer error and creating
class wrapping an enum is also questionable in this particular case.

Best regards,

View this message in context:
Sent from the OpenJPA Users mailing list archive at

View raw message