I am working on an API for accessing data stored on a system. The system contains things like people, meetings, and the procedures associated with these meetings. My application will be strictly read-only.
I use Spring w / RowMapper to create objects such as " Person ", " Appointment " and " Procedure ". I have a DAO for each item. (i.e.: PersonDAO.getById() , PersonDAO.getByName() , ..).
The problem is that the Appointment has a reference to the Person object. In the Person object, it would be nice to have a link to these Person meetings, but if I start downloading them, it will become a circular link.
So, I guess my question is the right way to handle this, just put the links (identifiers) in the POJO, and then at the business level (?) Just make the right calls to get the information? Or is it ok to somehow pass a reference to a DAO in an actual POJO so that I can lazily load object objects on a link? But then how do you handle a circular link? When I have a Person and lazily upload all their appointments, these appointments will also have a person associated with them. When I load this Person , it can potentially have information about the differences from Person I load the "Destinations" for.
Person (object x) lazy load -> Assignments can lazily load Person (object x ').
Since Person could have changed by the time I started lazily loading their appointments. I really need a Person object in Appointment to refer to the same Person object.
I understand. I know that I can just “make it work,” but I want to try and find a good solution. I thought about using hibernation for this, but thought it was really just an excess. Perhaps this is not so.
java hibernate circular-reference lazy-loading
jr.
source share