Uploaded image for project: 'Hibernate OGM'
  1. OGM-591

Persist OneToOne associations as singular attribute in MongoDB

    Details

    • Last commented by a user?:
      true
    • Sprint:

      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:

      {
        "_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.

      {
        "_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().

        Attachments

          Issue links

            Activity

              People

              • Assignee:
                gunnar.morling Gunnar Morling
                Reporter:
                gunnar.morling Gunnar Morling
                Participants:
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: