We're updating the issue view to help you get more done. 

Persist OneToOne associations as singular attribute in MongoDB

Description

For one-to-one associations we persist an array for the main side rather than a single JSON property in MongoDB (and probably CouchDB as well). Taking OneToOneTest#testBidirectionalManyToOne() as an example, that's the actual vs. the expected persisted format:

1 2 3 4 5 6 7 8 9 10 11 12 { "_id" : "6866afaf-c5ee-4fee-9821-79b2ae2a63b7", "husband" : [ "ae25fe38-d532-415c-b12a-4c1f0f4782a8" ], "name" : "Bea" } { "_id" : "ae25fe38-d532-415c-b12a-4c1f0f4782a8", "name" : "Alex", "wife" : "6866afaf-c5ee-4fee-9821-79b2ae2a63b7" }

vs.

1 2 3 4 5 6 7 8 9 10 { "_id" : "6866afaf-c5ee-4fee-9821-79b2ae2a63b7", "husband" : "ae25fe38-d532-415c-b12a-4c1f0f4782a8", "name" : "Bea" } { "_id" : "ae25fe38-d532-415c-b12a-4c1f0f4782a8", "name" : "Alex", "wife" : "6866afaf-c5ee-4fee-9821-79b2ae2a63b7" }

As discussed on IRC we could add the information about the association type (OneToOne etc.) to AssociationKeyMetadata. This would allow the dialect to store a single field only when invoked for a one-to-one association via updateAssociation().

Environment

None

Status

Assignee

Gunnar Morling

Reporter

Gunnar Morling

Labels

Worked in

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Community Help Wanted

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Components

Fix versions

Priority

Major