I'm using MongoDB and have a collection called user_experiments.
Each element of user_experiments is like:
Code:
{
_id: ObjectId("abc"),
userId: "123"
experiments: {
"experiment1" : {"variantA" : "variantValue1",
"variantB", "VariantValue2"
"variantC", "VariantValue3"},
"experiment2" : {"variantD", "VariantValue4"}
}
}
The problem I'm having is mapping experiments.
Ideally in the my java class I would like to have a field like:
Code:
Map<String, Map<String, String>> experiments;
or
Code:
Map<String, ExperimentVariantMapping> experiments;
where ExperimentVariantMapping had a Map<String, String> inside of it.
But I've been unable to achieve this.
Seems like:
https://forum.hibernate.org/viewtopic.php?f=31&t=1039103https://forum.hibernate.org/viewtopic.php?f=31&t=1038740Discuss similar problems (my first try involved nested @ElementCollection annotations).
The one-to-many approach mentioned in the topics above seems to require an additional collection. This data already exists in a MongoDB in the above form so I really can't alter the DB structure. Is there a way I can map this as is in any form?