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 CriteriaLoader(IOuterJoinLoadable persister, ISessionFactoryImplementor factory, CriteriaImpl rootCriteria,
                              string rootEntityName, IDictionary <string, IFilter> enabledFilters)
            : base(factory, enabledFilters)
        {
            translator = new CriteriaQueryTranslator(factory, rootCriteria, rootEntityName, CriteriaQueryTranslator.RootSqlAlias);

            querySpaces = translator.GetQuerySpaces();

            CriteriaJoinWalker walker =
                new CriteriaJoinWalker(persister, translator, factory, rootCriteria, rootEntityName, enabledFilters);

            InitFromWalker(walker);

            _uncacheableCollectionPersisters = translator.UncacheableCollectionPersisters;
            userAliases               = walker.UserAliases;
            ResultTypes               = walker.ResultTypes;
            includeInResultRow        = walker.IncludeInResultRow;
            resultRowLength           = ArrayHelper.CountTrue(IncludeInResultRow);
            childFetchEntities        = walker.ChildFetchEntities;
            EntityFetchLazyProperties = walker.EntityFetchLazyProperties;
            // fill caching objects only if there is a projection
            if (translator.HasProjection)
            {
                cachedProjectedColumnAliases = translator.ProjectedColumnAliases;
            }

            PostInstantiate();
        }
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)
            {
                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.º 4
0
		public CriteriaLoader(IOuterJoinLoadable persister, ISessionFactoryImplementor factory, CriteriaImpl rootCriteria,
							  string rootEntityName, IDictionary<string, IFilter> enabledFilters)
			: base(factory, enabledFilters)
		{
			translator = new CriteriaQueryTranslator(factory, rootCriteria, rootEntityName, CriteriaQueryTranslator.RootSqlAlias);

			querySpaces = translator.GetQuerySpaces();

			CriteriaJoinWalker walker =
				new CriteriaJoinWalker(persister, translator, factory, rootCriteria, rootEntityName, enabledFilters);

			InitFromWalker(walker);

			userAliases = walker.UserAliases;
			resultTypes = walker.ResultTypes;
			includeInResultRow = walker.IncludeInResultRow;
			resultRowLength = ArrayHelper.CountTrue(IncludeInResultRow);
			// fill caching objects only if there is a projection
			if (translator.HasProjection)
			{
				cachedProjectedColumnAliases = translator.ProjectedColumnAliases;
			}

			PostInstantiate();
		}
		public CriteriaLoader(
			IOuterJoinLoadable persister,
			ISessionFactoryImplementor factory,
			CriteriaImpl rootCriteria,
			System.Type rootEntityName, // TODO H3: change to string rootEntityName
			IDictionary enabledFilters)
			: base(factory, enabledFilters)
		{
			translator = new CriteriaQueryTranslator(
				factory,
				rootCriteria,
				rootEntityName,
				CriteriaQueryTranslator.RootSqlAlias);

			querySpaces = translator.GetQuerySpaces();

			CriteriaJoinWalker walker = new CriteriaJoinWalker(
				persister,
				translator,
				factory,
				rootCriteria,
				rootEntityName,
				enabledFilters);

			InitFromWalker(walker);

			userAliases = walker.UserAliases;
			resultTypes = walker.ResultTypes;

			PostInstantiate();
		}
        private void CreateSubQuerySpaces()
        {
            var subQueries =
                rootCriteria.IterateExpressionEntries()
                .Select(x => x.Criterion)
                .OfType <SubqueryExpression>()
                .Select(x => x.Criteria)
                .OfType <CriteriaImpl>();

            foreach (var criteriaImpl in subQueries)
            {
                //The RootSqlAlias is not relevant, since we're only retreiving the query spaces
                var translator = new CriteriaQueryTranslator(sessionFactory, criteriaImpl, criteriaImpl.EntityOrClassName, RootSqlAlias);
                subQuerySpaces.UnionWith(translator.GetQuerySpaces());
            }
        }
Exemplo n.º 7
0
        public CriteriaLoader(IOuterJoinLoadable persister, ISessionFactoryImplementor factory, CriteriaImpl rootCriteria,
                              string rootEntityName, IDictionary <string, IFilter> enabledFilters)
            : base(factory, enabledFilters)
        {
            translator = new CriteriaQueryTranslator(factory, rootCriteria, rootEntityName, CriteriaQueryTranslator.RootSqlAlias);

            querySpaces = translator.GetQuerySpaces();

            CriteriaJoinWalker walker =
                new CriteriaJoinWalker(persister, translator, factory, rootCriteria, rootEntityName, enabledFilters);

            InitFromWalker(walker);

            userAliases = walker.UserAliases;
            resultTypes = walker.ResultTypes;

            PostInstantiate();
        }
Exemplo n.º 8
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();
			}
		}
		private void CreateSubQuerySpaces()
		{

			var subQueries =
				rootCriteria.IterateExpressionEntries()
				            .Select(x => x.Criterion)
				            .OfType<SubqueryExpression>()
				            .Select(x => x.Criteria)
				            .OfType<CriteriaImpl>();

			foreach (var criteriaImpl in subQueries)
			{
				//The RootSqlAlias is not relevant, since we're only retreiving the query spaces
				var translator = new CriteriaQueryTranslator(sessionFactory, criteriaImpl, criteriaImpl.EntityOrClassName, RootSqlAlias);
				subQuerySpaces.UnionWith(translator.GetQuerySpaces());
			}

		}