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.
So,
<Source>
...
@OneToMany(mappedBy="source",cascade=CascadeType.ALL)
@MapKey(name="tsType")
private Map<Integer, TSImpl> tsMap;
...
</Source>
<TSimpl>
@Id
@Basic(optional=false)
@Enumerated(EnumType.ORDINAL)
@Column(name="tsType",updatable=false)
private TSType tsType; //stays as enum, same exception thrown
</TSImpl>
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.
@Id
@Basic(optional=false)
// @Enumerated(EnumType.ORDINAL)
@Column(name="tsType",updatable=false)
// 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,
Krzysztof
--
View this message in context: http://n2.nabble.com/Enum-as-a-Key-in-a-Map-tp1639596p1639929.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.
|