[hibernate-dev] [OGM] Mapping associations in MongoDB

Emmanuel Bernard emmanuel at hibernate.org
Wed Apr 25 03:33:51 EDT 2012


## Mapping strategy

I think we have explored three main options while implementing the association mapping in MongoDB

1. Put the assoc info within the entity document we navigate from
2. Put the assoc info in a dedicated document and dedicated collection
3. Put the assoc info in n documents (one doc per row) and a dedicated collection

And slightly orthogonal to this, we have considered to use a prefix for the association collection to make sure it does not clash when mapping @ManyToOne @JoinColumn.

I am reading MongoDB in Action and it seems option 1 is the most natural for MongoDB. At least let's offer the option via a property collected by the datastore / dialect. We can decide to reduce options down the road we we have a better grasp. And that will prevent rewriting the dialect every tie someone changes his mind (like me ;P)

## Optimizing what is store

We definitely store the same data over and over (like the table in association rows. At some point we probably will want to clean that up to do a more "natural" mapping.

(More) thoughts on associations?

Emmanuel

PS: this is nothing new but I'd rather capture this info by mail rather than via IRC discussions to consolidate it.


More information about the hibernate-dev mailing list