Exemplo n.º 1
0
        public CriteriaJoinWalker(IOuterJoinLoadable persister,CriteriaQueryTranslator translator,
            ISessionFactoryImplementor factory, CriteriaImpl criteria, string rootEntityName,
            IDictionary<string, IFilter> enabledFilters)
            : base(translator.RootSQLAlias, persister, factory, enabledFilters)
        {
            this.translator = translator;

            querySpaces = translator.GetQuerySpaces();

            if (translator.HasProjection)
            {
                resultTypes = translator.ProjectedTypes;

                InitProjection(
                    translator.GetSelect(enabledFilters),
                    translator.GetWhereCondition(enabledFilters),
                    translator.GetOrderBy(),
                    translator.GetGroupBy().ToString(),
                    LockMode.None
                    );
            }
            else
            {
                resultTypes = new IType[] {TypeFactory.ManyToOne(persister.EntityName)};

                InitAll(translator.GetWhereCondition(enabledFilters), translator.GetOrderBy(), LockMode.None);
            }

            userAliasList.Add(criteria.Alias); //root entity comes *last*
            userAliases = ArrayHelper.ToStringArray(userAliasList);
        }
Exemplo n.º 2
0
        public CriteriaJoinWalker(IOuterJoinLoadable persister, CriteriaQueryTranslator translator,
                                  ISessionFactoryImplementor factory, ICriteria criteria, string rootEntityName,
                                  IDictionary <string, IFilter> enabledFilters)
            : base(translator.RootSQLAlias, persister, factory, enabledFilters)
        {
            this.translator = translator;

            querySpaces = translator.GetQuerySpaces();

            if (translator.HasProjection)
            {
                resultTypes = translator.ProjectedTypes;

                InitProjection(
                    translator.GetSelect(enabledFilters),
                    translator.GetWhereCondition(enabledFilters),
                    translator.GetOrderBy(),
                    translator.GetGroupBy(),
                    translator.GetHavingCondition(enabledFilters),
                    enabledFilters,
                    LockMode.None);
            }
            else
            {
                resultTypes = new IType[] { TypeFactory.ManyToOne(persister.EntityName) };

                InitAll(translator.GetWhereCondition(enabledFilters), translator.GetOrderBy(), LockMode.None);
            }

            userAliasList.Add(criteria.Alias);             //root entity comes *last*
            userAliases = userAliasList.ToArray();
        }
Exemplo n.º 3
0
        public CriteriaJoinWalker(IOuterJoinLoadable persister, CriteriaQueryTranslator translator,
                                  ISessionFactoryImplementor factory, ICriteria criteria, string rootEntityName,
                                  IDictionary <string, IFilter> enabledFilters)
            : base(translator.RootSQLAlias, persister, factory, enabledFilters)
        {
            this.translator = translator;

            querySpaces = translator.GetQuerySpaces();

            if (translator.HasProjection)
            {
                InitProjection(
                    translator.GetSelect(),
                    translator.GetWhereCondition(),
                    translator.GetOrderBy(),
                    translator.GetGroupBy(),
                    translator.GetHavingCondition(),
                    enabledFilters,
                    LockMode.None,
                    translator.GetEntityProjections());

                resultTypes        = translator.ProjectedTypes;
                userAliases        = translator.ProjectedAliases;
                includeInResultRow = new bool[resultTypes.Length];
                ArrayHelper.Fill(IncludeInResultRow, true);
            }
            else
            {
                InitAll(translator.GetWhereCondition(), translator.GetOrderBy(), LockMode.None);

                resultTypes = new IType[] { TypeFactory.ManyToOne(persister.EntityName) };

                // root entity comes last
                userAliasList.Add(criteria.Alias);                 //root entity comes *last*
                resultTypeList.Add(translator.ResultType(criteria));
                includeInResultRowList.Add(true);
                userAliases        = userAliasList.ToArray();
                resultTypes        = resultTypeList.ToArray();
                includeInResultRow = includeInResultRowList.ToArray();
            }
        }
		public CriteriaJoinWalker(IOuterJoinLoadable persister, CriteriaQueryTranslator translator,
		                          ISessionFactoryImplementor factory, ICriteria criteria, string rootEntityName,
		                          IDictionary<string, IFilter> enabledFilters)
			: base(translator.RootSQLAlias, persister, factory, enabledFilters)
		{
			this.translator = translator;

			querySpaces = translator.GetQuerySpaces();

			if (translator.HasProjection)
			{
				InitProjection(
					translator.GetSelect(enabledFilters),
					translator.GetWhereCondition(enabledFilters),
					translator.GetOrderBy(),
					translator.GetGroupBy(),
					translator.GetHavingCondition(enabledFilters),
					enabledFilters, 
					LockMode.None);

				resultTypes = translator.ProjectedTypes;
				userAliases = translator.ProjectedAliases;
				includeInResultRow = new bool[resultTypes.Length];
				ArrayHelper.Fill(IncludeInResultRow, true);
			}
			else
			{
				InitAll(translator.GetWhereCondition(enabledFilters), translator.GetOrderBy(), LockMode.None);

				resultTypes = new IType[] { TypeFactory.ManyToOne(persister.EntityName) };

				// root entity comes last
				userAliasList.Add(criteria.Alias); //root entity comes *last*
				resultTypeList.Add(translator.ResultType(criteria));
				includeInResultRowList.Add(true);
				userAliases = userAliasList.ToArray();
				resultTypes = resultTypeList.ToArray();
				includeInResultRow = includeInResultRowList.ToArray();
			}
		}
		protected void InitProjection(CriteriaQueryTranslator translator, 
			IDictionary<string, IFilter> enabledFilters, LockMode lockMode)
		{
			// the order of the calls here is important, as the join clauses can contain parameter bindings
			SqlString projectionString = translator.GetSelect(enabledFilters);
			WalkEntityTree(persister, Alias);
			SqlString whereString = translator.GetWhereCondition(enabledFilters);
			SqlString orderByString = translator.GetOrderBy();
			SqlString groupByString = translator.GetGroupBy();
			SqlString havingString = translator.GetHavingCondition(enabledFilters);
			
			Persisters = new ILoadable[0];
			InitStatementString(projectionString, whereString, orderByString, groupByString.ToString(), 
                havingString, lockMode);
		}