Example #1
0
		public QueryMetadata(string sourceQuery, ParameterMetadata parameterMetadata, 
			string[] returnAliases, IType[] returnTypes, ISet<string> querySpaces)
		{
			this.sourceQuery = sourceQuery;
			this.parameterMetadata = parameterMetadata;
			this.returnAliases = returnAliases;
			this.returnTypes = returnTypes;
			this.querySpaces = querySpaces;
		}
Example #2
0
		public QueryImpl(string queryString, ISessionImplementor session, ParameterMetadata parameterMetadata)
			: this(queryString, FlushMode.Unspecified, session, parameterMetadata)
		{
		}
Example #3
0
		public QueryImpl(string queryString, FlushMode flushMode, ISessionImplementor session, ParameterMetadata parameterMetadata)
			: base(queryString, flushMode, session, parameterMetadata)
		{
		}
		public ExpressionQueryImpl(IQueryExpression queryExpression, ISessionImplementor session, ParameterMetadata parameterMetadata)
			: base(queryExpression.Key, FlushMode.Unspecified, session, parameterMetadata)
		{
			QueryExpression = queryExpression;
		}
Example #5
0
        protected internal HQLQueryPlan(string hql, string collectionRole, bool shallow,
                                        IDictionary <string, IFilter> enabledFilters, ISessionFactoryImplementor factory)
        {
            sourceQuery  = hql;
            this.shallow = shallow;

            enabledFilterNames = new HashedSet <string>(enabledFilters.Keys);

            HashedSet <string> combinedQuerySpaces = new HashedSet <string>();

            string[] concreteQueryStrings = QuerySplitter.ConcreteQueries(hql, factory);
            int      length = concreteQueryStrings.Length;

            translators = new IQueryTranslator[length];
            List <string> sqlStringList = new List <string>();

            for (int i = 0; i < length; i++)
            {
                if (collectionRole == null)
                {
                    translators[i] =
                        factory.Settings.QueryTranslatorFactory.CreateQueryTranslator(hql, concreteQueryStrings[i], enabledFilters,
                                                                                      factory);
                    translators[i].Compile(factory.Settings.QuerySubstitutions, shallow);
                }
                else
                {
                    translators[i] =
                        factory.Settings.QueryTranslatorFactory.CreateFilterTranslator(hql, concreteQueryStrings[i], enabledFilters,
                                                                                       factory);
                    ((IFilterTranslator)translators[i]).Compile(collectionRole, factory.Settings.QuerySubstitutions, shallow);
                }
                foreach (string qs in translators[i].QuerySpaces)
                {
                    combinedQuerySpaces.Add(qs);
                }
                sqlStringList.AddRange(translators[i].CollectSqlStrings);
            }

            sqlStrings  = sqlStringList.ToArray();
            querySpaces = combinedQuerySpaces;

            if (length == 0)
            {
                parameterMetadata = new ParameterMetadata(null, null);
                returnMetadata    = null;
            }
            else
            {
                parameterMetadata = BuildParameterMetadata(translators[0].GetParameterTranslations(), hql);
                if (translators[0].IsManipulationStatement)
                {
                    returnMetadata = null;
                }
                else
                {
                    if (length > 1)
                    {
                        int returns = translators[0].ReturnTypes.Length;
                        returnMetadata = new ReturnMetadata(translators[0].ReturnAliases, new IType[returns]);
                    }
                    else
                    {
                        returnMetadata = new ReturnMetadata(translators[0].ReturnAliases, translators[0].ReturnTypes);
                    }
                }
            }
        }