Ejemplo n.º 1
0
        public override SqlString SelectFragment(string alias, string suffix, bool includeCollectionColumns)
        {
            IOuterJoinLoadable ojl = (IOuterJoinLoadable)ElementPersister;

            if (includeCollectionColumns)
            {
                // Super impl will ignore suffix for collection columns!
                return(SelectFragment(alias).Append(StringHelper.CommaSpace).Append(ojl.SelectFragment(alias, suffix)));
            }
            else
            {
                // Use suffix for the entity columns.
                return(ojl.SelectFragment(alias, suffix));
            }
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
        public override string SelectFragment(IJoinable rhs, string rhsAlias, string lhsAlias, string entitySuffix,
                                              string collectionSuffix, bool includeCollectionColumns)
        {
            StringBuilder buf = new StringBuilder();

            if (includeCollectionColumns)
            {
                buf.Append(SelectFragment(lhsAlias, collectionSuffix)).Append(StringHelper.CommaSpace);
            }

            IOuterJoinLoadable ojl = (IOuterJoinLoadable)ElementPersister;

            return(buf.Append(ojl.SelectFragment(lhsAlias, entitySuffix))             //use suffix for the entity columns
                   .ToString());
        }