void BuildMetaData()
        {
            if (Translators.Length == 0)
            {
                ParameterMetadata = new ParameterMetadata(null, null);
                ReturnMetadata    = null;
            }
            else
            {
                ParameterMetadata = Translators[0].BuildParameterMetadata();

                if (Translators[0].IsManipulationStatement)
                {
                    ReturnMetadata = null;
                }
                else
                {
                    if (Translators.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);
                    }
                }
            }
        }
Beispiel #2
0
		private static void Check(ReturnMetadata returnMetadata, bool expectingEmptyTypes, bool expectingEmptyAliases)
		{
			Assert.IsNotNull(returnMetadata, "null return metadata");
			Assert.IsNotNull(returnMetadata, "null return metadata - types");
			Assert.AreEqual(1, returnMetadata.ReturnTypes.Length, "unexpected return size");

			if (expectingEmptyTypes)
			{
				Assert.IsNull(returnMetadata.ReturnTypes[0], "non-empty types");
			}
			else
			{
				Assert.IsNotNull(returnMetadata.ReturnTypes[0], "empty types");
			}

			if (expectingEmptyAliases)
			{
				Assert.IsNull(returnMetadata.ReturnAliases, "non-empty aliases");
			}
			else
			{
				Assert.IsNotNull(returnMetadata.ReturnAliases, "empty aliases");
				Assert.IsNotNull(returnMetadata.ReturnAliases[0], "empty aliases");
			}
		}
Beispiel #3
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);
                    }
                }
            }
        }