public void addFetch(Fetch fetch) {
Type associationType = fetch.getAssociation().getOwner().getPropertyType( fetch.getAssociation().getAssociationPath() );
if ( associationType.isCollectionType() ) {
log.trace( "handling request to add collection fetch [{}]", fetch.getAssociation().getRole() );
// couple of things for whcih to account in the case of collection
// join fetches
if ( Fetch.Style.JOIN == fetch.getStyle() ) {
// first, if this is a bag we need to ignore it if we previously
// processed collection join fetches
if ( BagType.class.isInstance( associationType ) ) {
if ( containsJoinFetchedCollection ) {
log.warn( "Ignoring bag join fetch [{}] due to prior collection join fetch", fetch.getAssociation().getRole() );
return; // EARLY EXIT!!!
}
}
// also, in cases where we are asked to add a collection join
// fetch where we had already added a bag join fetch previously,
// we need to go back and ignore that previous bag join fetch.
if ( containsJoinFetchedBag ) {
if ( fetches.remove( bagJoinFetch.getAssociation().getRole() ) != bagJoinFetch ) {
// just for safety...
log.warn( "Unable to erase previously added bag join fetch" );
}
bagJoinFetch = null;
containsJoinFetchedBag = false;
}
containsJoinFetchedCollection = true;
}
}
fetches.put( fetch.getAssociation().getRole(), fetch );
}
Add a fetch to the profile. |