In my java application, I have some entity, some of them may have the reference to another.
Say I have an Entity:
class Work{
User manager;
}
class User{
List works;
}
Then if I create one instance of Work, it will hold the reference of one user who will hold the reference of the Work.
I an afraid there will be an endless nest relation.
So I wonder if this is should be avoid or not?
There’s no problem with this bidirectional relationship. You seem to be worried about some kind of loop caused from traversing
UsertoWorkand back again etc.Ask yourself whether you require to get the
Works given aUserAND theUsergiven aWork. If this is the case then it makes sense to store the bidirectional references.