/** * Add a fetch to the profile. * * @param fetch The fetch to add. */ public void addFetch(final Fetch fetch) { final String fetchAssociactionRole = fetch.getAssociation().getRole(); final Type associationType = fetch.getAssociation().getOwner().getPropertyType( fetch.getAssociation().getAssociationPath() ); if ( associationType.isCollectionType() ) { LOG.tracev( "Handling request to add collection fetch [{0}]", fetchAssociactionRole ); // couple of things for which 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.containsJoinFetchedCollection( fetchAssociactionRole ); // EARLY EXIT!!! return; } } // 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 ) { // just for safety... if ( fetches.remove( bagJoinFetch.getAssociation().getRole() ) != bagJoinFetch ) { LOG.unableToRemoveBagJoinFetch(); } bagJoinFetch = null; containsJoinFetchedBag = false; } containsJoinFetchedCollection = true; } } fetches.put( fetchAssociactionRole, fetch ); }
public static CollectionClassification interpretCollectionClassification(CollectionType collectionType) { if ( collectionType instanceof BagType || collectionType instanceof IdentifierBagType ) { return CollectionClassification.BAG; } else if ( collectionType instanceof ListType || collectionType instanceof ArrayType ) { return CollectionClassification.LIST; } else if ( collectionType instanceof SetType || collectionType instanceof OrderedSetType || collectionType instanceof SortedSetType ) { return CollectionClassification.SET; } else if ( collectionType instanceof MapType || collectionType instanceof OrderedMapType || collectionType instanceof SortedMapType ) { return CollectionClassification.MAP; } else { final Class javaType = collectionType.getReturnedClass(); if ( Set.class.isAssignableFrom( javaType ) ) { return CollectionClassification.SET; } else if ( Map.class.isAssignableFrom( javaType ) ) { return CollectionClassification.MAP; } else if ( List.class.isAssignableFrom( javaType ) ) { return CollectionClassification.LIST; } return CollectionClassification.BAG; } }
private boolean isBag(CollectionPersister collectionPersister) { return collectionPersister.getCollectionType().getClass().isAssignableFrom( BagType.class ); }