I'm writing some sample codes in hibernate to understand the association and just started with One-One mapping. I ran into an issue where it says
Below are my codes
The reason which I'm thinking of here is when we say getStudent(), toString() method of Student class invoked as expected and in toString(), we have a reference of Address and it would invoke toString() method defined in Address class. This is getting into the infamous vicious circle of circular reference and finally throwing the error. I'm almost certain on this, as when I print only student name, it is working fine. But it is throwing error, when I try to refer Address from Student object.
1) Is my understanding of the error correct ? Or is there something else that could have caused the issue (which I'm certainly not hoping for).
2) Are there any hidden caveats in this code, which I should be aware of ?
3) How can this be better designed ?
But some how I'm thinking that this bidirectional association is not correctly designed and there is a high risk of circular dependencies and references. Is there any good approach/industry standard that can be suggested espicially while handling bidirectional assocation.