Imagine two classes of domain objects, Aand B. Ahas a one-to-many bidirectional relationship to B. Arefers to thousands B. Relations should be unique, it is impossible to duplicate.
To verify that the instance is Balready connected to this instance A, we could perform a simple one INNER JOIN, but this will only provide the stored relationship.
What about the current transitional relationship?
class A {
@OneToMany
private List<B> listOfB;
}
If we turn to listOfBand perform a check contains(), this will extract all related instances Bthat are lazy from the data source. I just want to check them by their primary key.
Is there a simple solution where I can do things like "Is this instance associated Awith this instance B?" without loading all this data into memory and doing a collection search?
source
share