private void InitStatementString(IOuterJoinLoadable elementPersister, string alias, int batchSize, SqlString subquery) { int joins = CountEntityPersisters(associations); Suffixes = BasicLoader.GenerateSuffixes(joins + 1); int collectionJoins = CountCollectionPersisters(associations) + 1; CollectionSuffixes = BasicLoader.GenerateSuffixes(joins + 1, collectionJoins); SqlStringBuilder whereString = WhereString(oneToManyPersister.GenerateTableAliasForKeyColumns(alias), oneToManyPersister.KeyColumnNames, subquery, batchSize); string filter = oneToManyPersister.FilterFragment(alias, EnabledFilters); whereString.Insert(0, StringHelper.MoveAndToBeginning(filter)); JoinFragment ojf = MergeOuterJoins(associations); SqlSelectBuilder select = new SqlSelectBuilder(Factory).SetSelectClause( oneToManyPersister.SelectFragment(null, null, alias, Suffixes[joins], CollectionSuffixes[0], true) + SelectString(associations)).SetFromClause(elementPersister.FromTableFragment(alias) + oneToManyPersister.FromJoinFragment(alias, true, true)).SetWhereClause( whereString.ToSqlString()).SetOuterJoins(ojf.ToFromFragmentString, ojf.ToWhereFragmentString + elementPersister.WhereJoinFragment(alias, true, true)); select.SetOrderByClause(OrderBy(associations, oneToManyPersister.GetSQLOrderByString(alias))); if (Factory.Settings.IsCommentsEnabled) { select.SetComment("load one-to-many " + oneToManyPersister.Role); } SqlString = select.ToSqlString(); }
/// <summary> /// Generate a sequence of <c>LEFT OUTER JOIN</c> clauses for the given associations. /// </summary> protected JoinFragment MergeOuterJoins(IList <OuterJoinableAssociation> associations) { JoinFragment outerjoin = Dialect.CreateOuterJoinFragment(); OuterJoinableAssociation last = null; foreach (OuterJoinableAssociation oj in associations) { if (last != null && last.IsManyToManyWith(oj)) { oj.AddManyToManyJoin(outerjoin, (IQueryableCollection)last.Joinable); } else { oj.AddJoins(outerjoin); // NH Different behavior : NH1179 and NH1293 // Apply filters in Many-To-One association if (enabledFiltersForManyToOne.Count > 0) { string manyToOneFilterFragment = oj.Joinable.FilterFragment(oj.RHSAlias, enabledFiltersForManyToOne); bool joinClauseDoesNotContainsFilterAlready = outerjoin.ToFromFragmentString.IndexOfCaseInsensitive(manyToOneFilterFragment) == -1; if (joinClauseDoesNotContainsFilterAlready) { outerjoin.AddCondition(manyToOneFilterFragment); } } } last = oj; } return(outerjoin); }
private void InitStatementString(SqlString projection, SqlString condition, SqlString orderBy, string groupBy, SqlString having, LockMode lockMode) { int joins = CountEntityPersisters(associations); Suffixes = BasicLoader.GenerateSuffixes(joins + 1); JoinFragment ojf = MergeOuterJoins(associations); SqlString selectClause = projection ?? new SqlString(persister.SelectFragment(alias, Suffixes[joins]) + SelectString(associations)); SqlSelectBuilder select = new SqlSelectBuilder(Factory) .SetLockMode(lockMode) .SetSelectClause(selectClause) .SetFromClause(Dialect.AppendLockHint(lockMode, persister.FromTableFragment(alias)) + persister.FromJoinFragment(alias, true, true)) .SetWhereClause(condition) .SetOuterJoins(ojf.ToFromFragmentString, ojf.ToWhereFragmentString + WhereFragment) .SetOrderByClause(OrderBy(associations, orderBy)) .SetGroupByClause(groupBy) .SetHavingClause(having); if (Factory.Settings.IsCommentsEnabled) { select.SetComment(Comment); } SqlString = select.ToSqlString(); }
private void AddSubclassJoins(JoinFragment joinFragment, String alias, IJoinable joinable, bool innerJoin, bool includeSubclassJoins) { bool include = includeSubclassJoins && IsIncluded(alias); joinFragment.AddJoins(joinable.FromJoinFragment(alias, innerJoin, include), joinable.WhereJoinFragment(alias, innerJoin, include)); }
private void AddExtraJoins(JoinFragment joinFragment, string alias, IJoinable joinable, bool innerJoin) { bool include = IsIncluded(alias); joinFragment.AddJoins(joinable.FromJoinFragment(alias, innerJoin, include), joinable.WhereJoinFragment(alias, innerJoin, include)); }
public override SqlString FromJoinFragment(string alias, bool innerJoin, bool includeSubclasses) { var elementJoinFragment = ((IJoinable)ElementPersister).FromJoinFragment(alias, innerJoin, includeSubclasses); if (CollectionType.UseLHSPrimaryKey) { return(elementJoinFragment); } JoinFragment join = Factory.Dialect.CreateOuterJoinFragment(); var lhsKeyColumnNames = new string[JoinColumnNames.Length]; int k = 0; foreach (string columnName in JoinColumnNames) { lhsKeyColumnNames[k] = alias + StringHelper.Dot + columnName; k++; } var ownerPersister = (IOuterJoinLoadable)OwnerEntityPersister; join.AddJoin(ownerPersister.TableName, GenerateTableAliasForKeyColumns(alias), lhsKeyColumnNames, ownerPersister.GetPropertyColumnNames(CollectionType.LHSPropertyName), innerJoin ? JoinType.InnerJoin : JoinType.LeftOuterJoin); return(join.ToFromFragmentString + elementJoinFragment); }
private void InitStatementString(IQueryableCollection persister, string alias, IList associations, int batchSize, ISessionFactoryImplementor factory) { Suffixes = GenerateSuffixes(associations.Count); SqlStringBuilder whereString = WhereString(factory, alias, persister.KeyColumnNames, persister.KeyType, batchSize); if (persister.HasWhere) { whereString .Add(" and ") .Add(persister.GetSQLWhereString(alias)); } JoinFragment ojf = MergeOuterJoins(associations); SqlSelectBuilder select = new SqlSelectBuilder(factory) .SetSelectClause( persister.SelectFragment(alias).Append( SelectString(associations, factory)).ToString() ) .SetFromClause(persister.TableName, alias) .SetWhereClause(whereString.ToSqlString()) .SetOuterJoins( ojf.ToFromFragmentString, ojf.ToWhereFragmentString ); if (persister.HasOrdering) { select.SetOrderByClause(persister.GetSQLOrderByString(alias)); } SqlString = select.ToSqlString(); }
protected void InitStatementString( IList associations, SqlString condition, string orderBy, ISessionFactoryImplementor factory) { int joins = CountClassPersisters(associations); Suffixes = GenerateSuffixes(joins + 1); JoinFragment ojf = MergeOuterJoins(associations); this.SqlString = new SqlSelectBuilder(factory) .SetSelectClause( persister.SelectFragment(alias, Suffixes[joins]) + SelectString(associations, factory) ) .SetFromClause( persister.FromTableFragment(alias).Append( persister.FromJoinFragment(alias, true, true)) ) .SetWhereClause(condition) .SetOuterJoins( ojf.ToFromFragmentString, ojf.ToWhereFragmentString.Append(GetWhereFragment()) ) .SetOrderByClause(orderBy) .ToSqlString(); }
private void AddJoin(JoinFragment ojf, QueryTranslator q) { JoinFragment fromClause = q.CreateJoinFragment(true); fromClause.AddJoins(ojf.ToFromFragmentString, new SqlString(String.Empty)); q.AddJoin(pathExpressionParser.Name, fromClause); //TODO: HACK with ToString() AddToCurrentJoin(ojf.ToWhereFragmentString.ToString()); }
public void AddManyToManyJoin(JoinFragment outerjoin, IQueryableCollection collection) { string manyToManyFilter = collection.GetManyToManyFilterFragment(rhsAlias, enabledFilters); string condition = string.Empty.Equals(manyToManyFilter) ? on : string.Empty.Equals(on) ? manyToManyFilter : on + " and " + manyToManyFilter; outerjoin.AddJoin(joinable.TableName, rhsAlias, lhsColumns, rhsColumns, joinType, condition); outerjoin.AddJoins(joinable.FromJoinFragment(rhsAlias, false, true), joinable.WhereJoinFragment(rhsAlias, false, true)); }
public void AddWhereFragment( JoinFragment joinFragment, SqlString whereFragment, QueryNode query, FromElement fromElement, HqlSqlWalker hqlSqlWalker) { IRestrictableStatement rs = query; AddWhereFragment(joinFragment, whereFragment, rs, fromElement, hqlSqlWalker); }
public void AddManyToManyJoin(JoinFragment outerjoin, IQueryableCollection collection) { string manyToManyFilter = collection.GetManyToManyFilterFragment(rhsAlias, enabledFilters); SqlString condition = string.Empty.Equals(manyToManyFilter) ? on : SqlStringHelper.IsEmpty(on) ? new SqlString(manyToManyFilter) : on.Append(" and ").Append(manyToManyFilter); outerjoin.AddJoin(joinable.TableName, rhsAlias, lhsColumns, rhsColumns, joinType, condition); outerjoin.AddJoins(joinable.FromJoinFragment(rhsAlias, false, true), joinable.WhereJoinFragment(rhsAlias, false, true)); }
private void InitStatementString(string alias, int batchSize, SqlString subquery) { int joins = CountEntityPersisters(associations); int collectionJoins = CountCollectionPersisters(associations) + 1; Suffixes = BasicLoader.GenerateSuffixes(joins); CollectionSuffixes = BasicLoader.GenerateSuffixes(joins, collectionJoins); SqlStringBuilder whereString = WhereString(alias, collectionPersister.KeyColumnNames, subquery, batchSize); string manyToManyOrderBy = string.Empty; string filter = collectionPersister.FilterFragment(alias, EnabledFilters); if (collectionPersister.IsManyToMany) { // from the collection of associations, locate OJA for the // ManyToOne corresponding to this persister to fully // define the many-to-many; we need that OJA so that we can // use its alias here // TODO : is there a better way here? IAssociationType associationType = (IAssociationType)collectionPersister.ElementType; foreach (OuterJoinableAssociation oja in associations) { if (oja.JoinableType == associationType) { // we found it filter += collectionPersister.GetManyToManyFilterFragment(oja.RHSAlias, EnabledFilters); manyToManyOrderBy += collectionPersister.GetManyToManyOrderByString(oja.RHSAlias); } } } whereString.Insert(0, StringHelper.MoveAndToBeginning(filter)); JoinFragment ojf = MergeOuterJoins(associations); SqlSelectBuilder select = new SqlSelectBuilder(Factory) .SetSelectClause(collectionPersister.SelectFragment(alias, CollectionSuffixes[0]) + SelectString(associations)) .SetFromClause(collectionPersister.TableName, alias) .SetWhereClause(whereString.ToSqlString()) .SetOuterJoins(ojf.ToFromFragmentString, ojf.ToWhereFragmentString); select.SetOrderByClause(OrderBy(associations, MergeOrderings(collectionPersister.GetSQLOrderByString(alias), manyToManyOrderBy))); if (Factory.Settings.IsCommentsEnabled) { select.SetComment("load collection " + collectionPersister.Role); } SqlString = select.ToSqlString(); }
private void PrepareForIndex(QueryTranslator q) { IQueryableCollection collPersister = q.GetCollectionPersister(collectionRole); if (!collPersister.HasIndex) { throw new QueryException("unindexed collection before []"); } string[] indexCols = collPersister.IndexColumnNames; if (indexCols.Length != 1) { throw new QueryException("composite-index appears in []: " + path); } string[] keyCols = collPersister.KeyColumnNames; JoinFragment ojf = q.CreateJoinFragment(useThetaStyleJoin); ojf.AddCrossJoin(collPersister.TableName, collectionName); ojf.AddFromFragmentString(join.ToFromFragmentString); if (collPersister.IsOneToMany) { IQueryable persister = (IQueryable)collPersister.ElementPersister; ojf.AddJoins( ((IJoinable)persister).FromJoinFragment(collectionName, true, false), ((IJoinable)persister).WhereJoinFragment(collectionName, true, false) ); } if (!continuation) { AddJoin(collPersister.TableName, collectionName, keyCols); } join.AddCondition(collectionName, indexCols, " = "); string[] eltCols = collPersister.ElementColumnNames; CollectionElement elem = new CollectionElement(); elem.ElementColumns = StringHelper.Qualify(collectionName, eltCols); elem.Type = collPersister.ElementType; elem.IsOneToMany = collPersister.IsOneToMany; elem.Alias = collectionName; elem.Join = join; collectionElements.Add(elem); //addlast SetExpectingCollectionIndex(); q.AddCollection(collectionName, collectionRole); q.AddJoin(collectionName, ojf); }
/// <summary> /// Generate a sequence of <c>LEFT OUTER JOIN</c> clauses for the given associations. /// </summary> protected JoinFragment MergeOuterJoins(IList <OuterJoinableAssociation> associations) { JoinFragment outerjoin = Dialect.CreateOuterJoinFragment(); var sortedAssociations = GetSortedAssociations(associations); OuterJoinableAssociation last = null; foreach (OuterJoinableAssociation oj in sortedAssociations) { if (last != null && last.IsManyToManyWith(oj)) { oj.AddManyToManyJoin(outerjoin, (IQueryableCollection)last.Joinable); } else { // NH Different behavior : NH1179 and NH1293 // Apply filters for entity joins and Many-To-One associations SqlString filter = null; var enabledFiltersForJoin = oj.ForceFilter ? enabledFilters : enabledFiltersForManyToOne; if (oj.ForceFilter || enabledFiltersForJoin.Count > 0) { string manyToOneFilterFragment = oj.Joinable.FilterFragment(oj.RHSAlias, enabledFiltersForJoin); bool joinClauseDoesNotContainsFilterAlready = oj.On?.IndexOfCaseInsensitive(manyToOneFilterFragment) == -1; if (joinClauseDoesNotContainsFilterAlready) { filter = new SqlString(manyToOneFilterFragment); } } if (TableGroupJoinHelper.ProcessAsTableGroupJoin(new[] { oj }, new[] { oj.On, filter }, true, outerjoin, alias => true, factory)) { continue; } oj.AddJoins(outerjoin); // Ensure that the join condition is added to the join, not the where clause. // Adding the condition to the where clause causes left joins to become inner joins. if (SqlStringHelper.IsNotEmpty(filter)) { outerjoin.AddFromFragmentString(filter); } } last = oj; } return(outerjoin); }
/// <summary> /// Generate a sequence of <c>LEFT OUTER JOIN</c> clauses for the given associations. /// </summary> /// <param name="associations"></param> /// <returns></returns> protected JoinFragment MergeOuterJoins(IList associations) { JoinFragment outerjoin = dialect.CreateOuterJoinFragment(); foreach (OuterJoinLoader.OuterJoinableAssociation oj in associations) { outerjoin.AddJoin(oj.TableName, oj.Subalias, oj.ForeignKeyColumns, oj.PrimaryKeyColumns, oj.JoinType); outerjoin.AddJoins( oj.Joinable.FromJoinFragment(oj.Subalias, false, true), oj.Joinable.WhereJoinFragment(oj.Subalias, false, true) ); } return(outerjoin); }
private void AddJoinNodes(QueryNode query, JoinSequence join, FromElement fromElement) { JoinFragment joinFragment = join.ToJoinFragment( _walker.EnabledFilters, fromElement.UseFromFragment || fromElement.IsDereferencedBySuperclassOrSubclassProperty, fromElement.WithClauseFragment, fromElement.WithClauseJoinAlias ); SqlString frag = joinFragment.ToFromFragmentString; SqlString whereFrag = joinFragment.ToWhereFragmentString; // If the from element represents a JOIN_FRAGMENT and it is // a theta-style join, convert its type from JOIN_FRAGMENT // to FROM_FRAGMENT if (fromElement.Type == HqlSqlWalker.JOIN_FRAGMENT && (join.IsThetaStyle || StringHelper.IsNotEmpty(whereFrag))) { fromElement.Type = HqlSqlWalker.FROM_FRAGMENT; fromElement.JoinSequence.SetUseThetaStyle(true); // this is used during SqlGenerator processing } // If there is a FROM fragment and the FROM element is an explicit, then add the from part. if (fromElement.UseFromFragment /*&& StringHelper.isNotEmpty( frag )*/) { SqlString fromFragment = ProcessFromFragment(frag, join).Trim(); if (log.IsDebugEnabled) { log.Debug("Using FROM fragment [" + fromFragment + "]"); } ProcessDynamicFilterParameters( fromFragment, fromElement, _walker ); } _syntheticAndFactory.AddWhereFragment( joinFragment, whereFrag, query, fromElement, _walker ); }
/// <summary> /// Generate a sequence of <c>LEFT OUTER JOIN</c> clauses for the given associations. /// </summary> protected JoinFragment MergeOuterJoins(IList <OuterJoinableAssociation> associations) { IList <OuterJoinableAssociation> sortedAssociations = new List <OuterJoinableAssociation>(); var indices = GetTopologicalSortOrder(_dependentAliases); for (int index = indices.Length - 1; index >= 0; index--) { sortedAssociations.Add(associations[indices[index]]); } JoinFragment outerjoin = Dialect.CreateOuterJoinFragment(); OuterJoinableAssociation last = null; foreach (OuterJoinableAssociation oj in sortedAssociations) { if (last != null && last.IsManyToManyWith(oj)) { oj.AddManyToManyJoin(outerjoin, (IQueryableCollection)last.Joinable); } else { oj.AddJoins(outerjoin); // NH Different behavior : NH1179 and NH1293 // Apply filters in Many-To-One association if (enabledFiltersForManyToOne.Count > 0) { string manyToOneFilterFragment = oj.Joinable.FilterFragment(oj.RHSAlias, enabledFiltersForManyToOne); bool joinClauseDoesNotContainsFilterAlready = outerjoin.ToFromFragmentString.IndexOfCaseInsensitive(manyToOneFilterFragment) == -1; if (joinClauseDoesNotContainsFilterAlready) { // Ensure that the join condition is added to the join, not the where clause. // Adding the condition to the where clause causes left joins to become inner joins. outerjoin.AddFromFragmentString(new SqlString(manyToOneFilterFragment)); } } } last = oj; } return(outerjoin); }
public static string CreateCollectionSubquery( JoinSequence joinSequence, IDictionary <string, IFilter> enabledFilters, String[] columns) { try { JoinFragment join = joinSequence.ToJoinFragment(enabledFilters, true); return(new StringBuilder() .Append("select ") .Append(StringHelper.Join(", ", columns)) .Append(" from ") .Append(join.ToFromFragmentString.Substring(2)) // remove initial ", " .Append(" where ") .Append(join.ToWhereFragmentString.Substring(5)) // remove initial " and " .ToString()); } catch (MappingException me) { throw new QueryException(me); } }
public void AddJoins(JoinFragment outerjoin) { outerjoin.AddJoin(joinable.TableName, rhsAlias, lhsColumns, rhsColumns, joinType, on); outerjoin.AddJoins(joinable.FromJoinFragment(rhsAlias, false, true), joinable.WhereJoinFragment(rhsAlias, false, true)); }
public void AddWhereFragment( JoinFragment joinFragment, SqlString whereFragment, QueryNode query, FromElement fromElement, HqlSqlWalker hqlSqlWalker) { if (whereFragment == null) { return; } if (!fromElement.UseWhereFragment && !joinFragment.HasThetaJoins) { return; } whereFragment = whereFragment.Trim(); if (StringHelper.IsEmpty(whereFragment.ToString())) { return; } // Forcefully remove leading ands from where fragments; the grammar will // handle adding them if (whereFragment.StartsWithCaseInsensitive("and")) { whereFragment = whereFragment.Substring(4); } log.Debug("Using unprocessed WHERE-fragment [" + whereFragment + "]"); SqlFragment fragment = (SqlFragment)Create(HqlSqlWalker.SQL_TOKEN, whereFragment.ToString()); fragment.SetJoinFragment(joinFragment); fragment.FromElement = fromElement; if (fromElement.IndexCollectionSelectorParamSpec != null) { fragment.AddEmbeddedParameter(fromElement.IndexCollectionSelectorParamSpec); fromElement.IndexCollectionSelectorParamSpec = null; } if (hqlSqlWalker.IsFilter()) { //if (whereFragment.IndexOfCaseInsensitive("?") >= 0) if (whereFragment.ToString().IndexOf("?") >= 0) { IType collectionFilterKeyType = hqlSqlWalker.SessionFactoryHelper .RequireQueryableCollection(hqlSqlWalker.CollectionFilterRole) .KeyType; CollectionFilterKeyParameterSpecification paramSpec = new CollectionFilterKeyParameterSpecification( hqlSqlWalker.CollectionFilterRole, collectionFilterKeyType, 0 ); fragment.AddEmbeddedParameter(paramSpec); } } JoinProcessor.ProcessDynamicFilterParameters( whereFragment, fragment, hqlSqlWalker ); log.Debug("Using processed WHERE-fragment [" + fragment.Text + "]"); // Filter conditions need to be inserted before the HQL where condition and the // theta join node. This is because org.hibernate.loader.Loader binds the filter parameters first, // then it binds all the HQL query parameters, see org.hibernate.loader.Loader.processFilterParameters(). if (fragment.FromElement.IsFilter || fragment.HasFilterCondition) { if (_filters == null) { // Find or create the WHERE clause IASTNode where = (IASTNode)query.WhereClause; // Create a new FILTERS node as a parent of all filters _filters = Create(HqlSqlWalker.FILTERS, "{filter conditions}"); // Put the FILTERS node before the HQL condition and theta joins where.InsertChild(0, _filters); } // add the current fragment to the FILTERS node _filters.AddChild(fragment); } else { if (_thetaJoins == null) { // Find or create the WHERE clause IASTNode where = (IASTNode)query.WhereClause; // Create a new THETA_JOINS node as a parent of all filters _thetaJoins = Create(HqlSqlWalker.THETA_JOINS, "{theta joins}"); // Put the THETA_JOINS node before the HQL condition, after the filters. if (_filters == null) { where.InsertChild(0, _thetaJoins); } else { _filters.AddSibling(_thetaJoins); } } // add the current fragment to the THETA_JOINS node _thetaJoins.AddChild(fragment); } }
public void SetJoinFragment(JoinFragment joinFragment) { _joinFragment = joinFragment; }
public void Token(string token, QueryTranslator q) { if (token != null) { path += token; } string alias = q.GetPathAlias(path); if (alias != null) { Reset(q); //reset the dotcount (but not the path) currentName = alias; //after reset! currentPropertyMapping = q.GetPropertyMapping(currentName); if (!ignoreInitialJoin) { JoinFragment ojf = q.GetPathJoin(path); join.AddCondition(ojf.ToWhereFragmentString); //after reset! // we don't need to worry about any condition in the ON clause // here (toFromFragmentString), since anything in the ON condition // is already applied to the whole query } } else if (".".Equals(token)) { dotcount++; } else { if (dotcount == 0) { if (!continuation) { if (!q.IsName(token)) { throw new QueryException("undefined alias or unknown mapping: " + token); } currentName = token; currentPropertyMapping = q.GetPropertyMapping(currentName); } } else if (dotcount == 1) { if (currentName != null) { currentProperty = token; } else if (collectionName != null) { //IQueryableCollection p = q.GetCollectionPersister( collectionRole ); //DoCollectionProperty( token, p, collectionName ); continuation = false; } else { throw new QueryException("unexpected"); } } else { // dotcount>=2 // Do the corresponding RHS IType propertyType = PropertyType; if (propertyType == null) { throw new QueryException("unresolved property: " + currentProperty); } if (propertyType.IsComponentType) { DereferenceComponent(token); } else if (propertyType.IsEntityType) { DereferenceEntity(token, (EntityType)propertyType, q); } else if (propertyType.IsPersistentCollectionType) { DereferenceCollection(token, ((PersistentCollectionType)propertyType).Role, q); } else if (token != null) { throw new QueryException("dereferenced: " + currentProperty); } } } }
private bool ProcessAsTableGroupJoin(bool includeAllSubclassJoins, SqlString[] withClauseFragments, JoinFragment joinFragment) { if (!NeedsTableGroupJoin(joins, withClauseFragments, includeAllSubclassJoins)) { return(false); } var first = joins[0]; string joinString = ANSIJoinFragment.GetJoinString(first.JoinType); joinFragment.AddFromFragmentString( new SqlString( joinString, " (", first.Joinable.TableName, " ", first.Alias )); foreach (var join in joins) { if (join != first) { joinFragment.AddJoin( join.Joinable.TableName, join.Alias, join.LHSColumns, JoinHelper.GetRHSColumnNames(join.AssociationType, factory), join.JoinType, SqlString.Empty); } AddSubclassJoins( joinFragment, join.Alias, join.Joinable, // TODO (from hibernate): Think about if this could be made always true // NH Specific: made always true (original check: join.JoinType == JoinType.InnerJoin) true, includeAllSubclassJoins ); } var tableGroupWithClause = GetTableGroupJoinWithClause(withClauseFragments, first); joinFragment.AddFromFragmentString(tableGroupWithClause); return(true); }
internal static bool ProcessAsTableGroupJoin(IReadOnlyList <IJoin> tableGroupJoinables, SqlString[] withClauseFragments, bool includeAllSubclassJoins, JoinFragment joinFragment, Func <string, bool> isSubclassIncluded, ISessionFactoryImplementor sessionFactoryImplementor) { if (!NeedsTableGroupJoin(tableGroupJoinables, withClauseFragments, includeAllSubclassJoins)) { return(false); } var first = tableGroupJoinables[0]; string joinString = ANSIJoinFragment.GetJoinString(first.JoinType); joinFragment.AddFromFragmentString( new SqlString( joinString, " (", first.Joinable.TableName, " ", first.Alias )); foreach (var join in tableGroupJoinables) { if (join != first) { joinFragment.AddJoin( join.Joinable.TableName, join.Alias, join.LHSColumns, JoinHelper.GetRHSColumnNames(join.AssociationType, sessionFactoryImplementor), join.JoinType, SqlString.Empty); } bool include = includeAllSubclassJoins && isSubclassIncluded(join.Alias); // TODO (from hibernate): Think about if this could be made always true // NH Specific: made always true (original check: join.JoinType == JoinType.InnerJoin) const bool innerJoin = true; joinFragment.AddJoins( join.Joinable.FromJoinFragment(join.Alias, innerJoin, include), join.Joinable.WhereJoinFragment(join.Alias, innerJoin, include)); } var withClause = GetTableGroupJoinWithClause(withClauseFragments, first, sessionFactoryImplementor); joinFragment.AddFromFragmentString(withClause); return(true); }