protected void initPersisters( final List associations, final LockOptions lockOptions, final AssociationInitCallback callback) throws MappingException { final int joins = countEntityPersisters(associations); final int collections = countCollectionPersisters(associations); collectionOwners = collections == 0 ? null : new int[collections]; collectionPersisters = collections == 0 ? null : new CollectionPersister[collections]; collectionSuffixes = BasicLoader.generateSuffixes(joins + 1, collections); this.lockOptions = lockOptions; persisters = new Loadable[joins]; aliases = new String[joins]; owners = new int[joins]; ownerAssociationTypes = new EntityType[joins]; lockModeArray = ArrayHelper.fillArray(lockOptions.getLockMode(), joins); int i = 0; int j = 0; Iterator iter = associations.iterator(); while (iter.hasNext()) { final OuterJoinableAssociation oj = (OuterJoinableAssociation) iter.next(); if (!oj.isCollection()) { persisters[i] = (Loadable) oj.getJoinable(); aliases[i] = oj.getRHSAlias(); owners[i] = oj.getOwner(associations); ownerAssociationTypes[i] = (EntityType) oj.getJoinableType(); callback.associationProcessed(oj, i); i++; } else { QueryableCollection collPersister = (QueryableCollection) oj.getJoinable(); if (oj.getJoinType() == JoinType.LEFT_OUTER_JOIN && !oj.hasRestriction()) { // it must be a collection fetch collectionPersisters[j] = collPersister; collectionOwners[j] = oj.getOwner(associations); j++; } if (collPersister.isOneToMany()) { persisters[i] = (Loadable) collPersister.getElementPersister(); aliases[i] = oj.getRHSAlias(); callback.associationProcessed(oj, i); i++; } } } if (ArrayHelper.isAllNegative(owners)) owners = null; if (collectionOwners != null && ArrayHelper.isAllNegative(collectionOwners)) { collectionOwners = null; } }
public boolean isManyToManyWith(OuterJoinableAssociation other) { if (joinable.isCollection()) { QueryableCollection persister = (QueryableCollection) joinable; if (persister.isManyToMany()) { return persister.getElementType() == other.getJoinableType(); } } return false; }