Hi Magnus,
Ideally you would be able to do this using a MapContainerPolicy.
Unfortunately, the MapContainerPolicy doesn't really support
heterogeneous collections, as it assumes there's just 1 element
class and 1 field/method that is used to obtain the key from the
element when populating the map.
You could handle this case with a custom attribute accessor that
just returns the values() from the Map on the
getAttributeValueFromObject and manually builds the map from the
list on setAttributeValueInObject.
If you'd like to open an EclipseLink bug about MapContainerPolicy
not being supported by XMLChoiceCollectionMappings, that is
something we could definitely support in the future.
Hope that helps,
-Matt
On 21/09/2011 3:12 AM, Magnus Heino wrote:
Hi.
I have this mapping that maps to an ArrayList. Is it possible to
change it to a HashMap?
XMLChoiceCollectionMapping add = new
XMLChoiceCollectionMapping();
add.setAttributeName("add");
add.addChoiceElement("ex:Nytt/landreg:IR_Fastighet",
IR_Fastighet.class);
add.addChoiceElement("ex:Nytt/landreg:Gruppinformation",
Gruppinformation.class);
add.addChoiceElement("ex:Nytt/landreg:IM_Omrade",
IM_Omrade.class);
add.addChoiceElement("ex:Nytt/landreg:IM_PagaendeArende",
IM_PagaendeArende.class);
add.addChoiceElement("ex:Nytt/landreg:Inteckning",
Inteckning.class);
add.addChoiceElement("ex:Nytt/landreg:Inteckningsanmarkning",
Inteckningsanmarkning.class);
add.addChoiceElement("ex:Nytt/landreg:Innehavsanteckning",
Innehavsanteckning.class);
add.addChoiceElement("ex:Nytt/landreg:OvrigInnehavare",
OvrigInnehavare.class);
add.addChoiceElement("ex:Nytt/landreg:IR_Belastar",
IR_Belastar.class);
add.addChoiceElement("ex:Nytt/landreg:Inskrivningshandelse",
Inskrivningshandelse.class);
add.addChoiceElement("ex:Nytt/ex:Verksamhetsarende",
BusinessCase.class);
add.useCollectionClass(ArrayList.class);
forandring.addMapping(add);
--
/Magnus Heino
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
|