I have read
looking for solutions to map One-To-One relationships. However, those demos in the articles are all Many-To-One or One-To-Many. From the demo, I conclude that in most cases, we will annotate the ONE side as @JsonManagedReference and the MANY side as @JsonBackReference.
However, there's no hint about how to map One-To-One. Do you have any idea?
Also, what if it is a bi-directional one-to-one?
You can think of it as just a special case of one-to-many; so you will annotate reference from 'parent' to 'child' as @JsonManagedReference, and 'child' to 'parent' as @JsonBackReference.
One more document that might be helpful is the one at FasterXML Jackson Wiki; first example is for one-to-one relationship, and should be applicable for your case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With