I'm experimenting with OGM and MongoDB with a JPA annotated model. I have an entity/class that contains an embedded collection:
Code:
@ElementCollection()
public java.util.List<Context> getContext() {
with Context.java being:
Code:
@Embeddable
public class Context implements java.io.Externalizable {
private Type _type=Type.Conversation;
private String _value=null;
.....
// suitable accessors and modifiers for these two fields
When I examine some test data in the MongoDB, I see:
Code:
{ "_id" : { "unitId" : "au1", "unitIndex" : 0 }, "context" : [ { "context.collection&&element.type" : 2, "context.collection&&element.value" : "corr1" }, { "context.collection&&element.type" : 0, "context.collection&&element.value" : "12345" } ], "properties" : [ { "name" : "customer", "value" : "Fred" }, { "name" : "trader", "value" : "Joe" } ] }
The 'properties' field is an element collection also, but a map as opposed to a list, but it seems to be represented as I would expect. However the context elements have unexpected field names?
Is there a way that these fields can simply have the 'type' and 'value' names that I would get if I serialized the object model to JSON?
Second question relates to the way enumerated types are stored. The 'type' field is an enumerated type, and being stored as its numerical value. However a jackson/json serialized form uses the enumerated value's name rather than index, which from a query perspective seems more natural. Is there a way to configure the datastore provider to use this approach instead?
Thanks in advance.