/// <summary> /// Create a join sequence rooted at the given collection. /// </summary> /// <param name="collPersister">The persister for the collection at which the join should be rooted.</param> /// <param name="collectionName">The alias to use for qualifying column references.</param> /// <returns>The generated join sequence.</returns> public JoinSequence CreateCollectionJoinSequence(IQueryableCollection collPersister, String collectionName) { JoinSequence joinSequence = CreateJoinSequence(); joinSequence.SetRoot(collPersister, collectionName); joinSequence.SetUseThetaStyle(true); // TODO: figure out how this should be set. /////////////////////////////////////////////////////////////////////////////// // This was the reason for failures regarding INDEX_OP and subclass joins on // theta-join dialects; not sure what behaviour we were trying to emulate ;) // joinSequence = joinSequence.getFromPart(); // Emulate the old addFromOnly behavior. return joinSequence; }
IASTNode CreateFromFilterElement(IASTNode filterEntity, IASTNode alias) { var fromElementFound = true; var fromElement = _currentFromClause.GetFromElement(alias.Text) ?? _currentFromClause.GetFromElementByClassName(filterEntity.Text); if (fromElement == null) { fromElementFound = false; fromElement = _currentFromClause.AddFromElement(filterEntity.Text, alias); } FromClause fromClause = fromElement.FromClause; IQueryableCollection persister = _sessionFactoryHelper.GetCollectionPersister(_collectionFilterRole); // Get the names of the columns used to link between the collection // owner and the collection elements. String[] keyColumnNames = persister.KeyColumnNames; String fkTableAlias = persister.IsOneToMany ? fromElement.TableAlias : fromClause.AliasGenerator.CreateName(_collectionFilterRole); JoinSequence join = _sessionFactoryHelper.CreateJoinSequence(); join.SetRoot(persister, fkTableAlias); if (!persister.IsOneToMany) { join.AddJoin((IAssociationType)persister.ElementType, fromElement.TableAlias, JoinType.InnerJoin, persister.GetElementColumnNames(fkTableAlias)); } join.AddCondition(fkTableAlias, keyColumnNames, " = ", true); fromElement.JoinSequence = join; fromElement.Filter = true; if (log.IsDebugEnabled()) { log.Debug("createFromFilterElement() : processed filter FROM element."); } if (fromElementFound) { return((IASTNode)adaptor.Nil()); } return(fromElement); }