[hibernate-dev] [OGM] Distinguishing embedded collections and associations in document stores
Gunnar Morling
gunnar at hibernate.org
Fri Nov 29 05:49:22 EST 2013
Hi,
I'm working on support for embedded associations in CouchDB [1]. Checking
how this is mapped by the MongoDB dialect I saw its done like this (here
with an order column):
{
"_id": "123",
"orderedChildren": [
{
"birthorder": 0,
"orderedChildren_id": "456"
},
{
"birthorder": 1,
"orderedChildren_id": "789"
}
]
}
Just looking at this document one can't tell whether "orderedChildren"
actually represents an association or an embedded collection. For our
engine that's no problem as it knows the kind of the element from its
meta-model.
We have a testing approach though which makes assertions on the number of
associations stored in the database. With the representation described
above the number of embedded associations can't be determined on the
server-side alone (using a "view" in CouchDB terms).
Besides from adding an attribute which describes the kind of a collection
(which wouldn't be so nice as it was just for testing purposes), I don't
see any other way than obtaining all the candidates and single out actual
associations on the client based on the meta-model.
Maybe anyone has a better idea?
Btw. for MongoDB the problem is ignored by having the assertion method
always return true in this case.
--Gunnar
[1] https://hibernate.atlassian.net/browse/OGM-389
More information about the hibernate-dev
mailing list