while ( tokens.hasMoreTokens() ) {
componentPath += tokens.nextToken();
Type type = provider.getType( componentPath );
if ( type.isAssociationType() ) {
// CollectionTypes are always also AssociationTypes - but there's not always an associated entity...
AssociationType atype = ( AssociationType ) type;
CollectionType ctype = type.isCollectionType() ? (CollectionType)type : null;
Type elementType = (ctype != null) ? ctype.getElementType( sessionFactory ) : null;
// is the association a collection of components or value-types? (i.e a colloction of valued types?)
if ( ctype != null && elementType.isComponentType() ) {
provider = new ComponentCollectionCriteriaInfoProvider( helper.getCollectionPersister(ctype.getRole()) );
}
else if ( ctype != null && !elementType.isEntityType() ) {
provider = new ScalarCollectionCriteriaInfoProvider( helper, ctype.getRole() );
}
else {
provider = new EntityCriteriaInfoProvider(( Queryable ) sessionFactory.getEntityPersister(
atype.getAssociatedEntityName( sessionFactory )
));
}
componentPath = "";
}