Related IRC discussion between Emmanuel and Gunnar:
[2:29pm] gmorling: emmanuel: hey [2:29pm] gmorling: emmanuel: can you take a look at OGM's OneToOneTest, method testBidirectionalManyToOne() [2:29pm] gmorling: there we have two entities, Husband and Wife [2:29pm] emmanuel: looking [2:29pm] gmorling: and there is a bi-di OneToOne association between them [2:30pm] gmorling: that's persisted as in the first file of this gist: https://gist.github.com/gunnarmorling/95ae61bf45cf420b1462 [2:30pm] gmorling: i'd expect the second, though. or do i miss a piece? [2:33pm] emmanuel: well yes that would be moderately better [2:33pm] gmorling: the current form seems misleading [2:33pm] gmorling: as its not an array of husbands really [2:33pm] emmanuel: this case is really technically a ManyToOne but where the app tells you that there is only one item on the many side [2:34pm] emmanuel: so in a RDBMS, it's enforced by a constraint [2:34pm] gmorling: now it's getting interesting [2:34pm] gmorling: because i was about to ask [2:34pm] gmorling: updateAssociation() is invoked for this [2:34pm] emmanuel: here indeed we could be a tiny bit better and save it as an item instead of an array [2:34pm] emmanuel: yes [2:34pm] gmorling: that's why the mongo dialect creates it as an array [2:35pm] gmorling: so orm creates a unique constraint on the fk column in this case? [2:35pm] emmanuel: yes [2:36pm] gmorling: i guess right now we wouldn't have a way to detect this situation in the dialect [2:36pm] gmorling: and handle it specially [2:38pm] emmanuel: we coudl only if AssociationKeyMetadata was carrying the OneToOne nature of it [2:38pm] emmanuel: which would be a good idea [2:38pm] gmorling: yes, something like that
|