[hibernate-dev] [OGM] Element collections stored embedded in entity

Gunnar Morling gunnar at hibernate.org
Wed Mar 12 06:21:06 EDT 2014


Hi,

I just did some testing around @ElementCollection using MongoDB. A
collection of a basic type results in the following persistent format of
the embedding entity:

    {
        "_id": "17457a47-abfc-4fb7-955e-17acb0b49808",
        "nicknames": [
            { "nicknames": "idrA" },
            { "nicknames": "day[9]" }
        ]
    }

Is there any reason why we don't use this instead:

    {
        "_id": "17457a47-abfc-4fb7-955e-17acb0b49808",
        "nicknames": [
            "idrA",
            "day[9]"
        ]
    }

For non-basic, embeddable types it looks like this:

    {
        "_id": "17457a47-abfc-4fb7-955e-17acb0b49808",
        "homeAddress": [
            {
                "homeAddress.collection&&element.city": "Paris",
                "homeAddress.collection&&element.country": "France",
                "homeAddress.collection&&element.street1": "1 avenue des
Champs Elysees",
                "homeAddress.collection&&element.street2": null,
                "postal_code": "75007"
            }
        ]
    }

Is this "collection&&element" style intended, or could we use the simple
property name as keys here ("postal_code" is specified explicitly via
@Column)?

I can file issues in JIRA (and take a look at some point), but wanted to be
sure I'm not missing something here.

Thanks,

--Gunnar


More information about the hibernate-dev mailing list