public void AddQueryReturn(INativeSQLQueryReturn queryReturn)
 {
     if (queryReturn != null)
     {
         queryReturns.Add(queryReturn);
     }
 }
		public SQLQueryContext(INativeSQLQueryReturn[] queryReturns, ISessionFactoryImplementor factory)
		{
			this.factory = factory;

			// first, break down the returns into maps keyed by alias
			// so that role returns can be more easily resolved to their owners
			foreach (INativeSQLQueryReturn rtn in queryReturns)
			{
				var nonScalarRtn = rtn as NativeSQLQueryNonScalarReturn;
				if (nonScalarRtn != null)
				{
					alias2Return[nonScalarRtn.Alias] = rtn;
					var joinRtn = rtn as NativeSQLQueryJoinReturn;
					if (joinRtn != null)
					{
						alias2OwnerAlias[joinRtn.Alias] = joinRtn.OwnerAlias;
					}
				}
			}

			// Now, process the returns
			foreach (INativeSQLQueryReturn rtn in queryReturns)
			{
				ProcessReturn(rtn);
			}
		}
		public void AddQueryReturn(INativeSQLQueryReturn queryReturn)
		{
			if (queryReturn != null)
			{
				queryReturns.Add(queryReturn);
			}
		}
		public NativeSQLQuerySpecification(
			string queryString,
			INativeSQLQueryReturn[] sqlQueryReturns,
			ICollection<string> querySpaces)
		{
			this.queryString = queryString;
			this.sqlQueryReturns = sqlQueryReturns;

			if (querySpaces == null)
			{
                this.querySpaces = new IESI.HashedSet<string>();
			}
			else
			{
                var tmp = new IESI.HashedSet<string>();
				tmp.AddAll(querySpaces);
				// Can't use ImmutableSet here because it doesn't implement GetHashCode properly.
				this.querySpaces = tmp;
			}

			// pre-determine and cache the hashcode
			int hCode = queryString.GetHashCode();
			unchecked
			{
				hCode = 29 * hCode + CollectionHelper.GetHashCode(this.querySpaces);
				if (this.sqlQueryReturns != null)
				{
					hCode = 29 * hCode + CollectionHelper.GetHashCode(this.sqlQueryReturns);
				}
			}

			hashCode = hCode;
		}
		public NativeSQLQuerySpecification(
			string queryString,
			INativeSQLQueryReturn[] sqlQueryReturns,
			ICollection<string> querySpaces)
		{
			this.queryString = queryString;
			this.sqlQueryReturns = sqlQueryReturns;

			this.querySpaces = new HashSet<string>();
			if (querySpaces != null)
				this.querySpaces.UnionWith(querySpaces);

			// pre-determine and cache the hashcode
			int hCode = queryString.GetHashCode();
			unchecked
			{
				hCode = 29 * hCode + CollectionHelper.GetHashCode(this.querySpaces);
				if (this.sqlQueryReturns != null)
				{
					hCode = 29 * hCode + CollectionHelper.GetHashCode(this.sqlQueryReturns);
				}
			}

			hashCode = hCode;
		}
		public NamedSQLQueryDefinition(
			string query,
			INativeSQLQueryReturn[] queryReturns,
			IList<string> querySpaces,
			bool cacheable,
			string cacheRegion,
			int timeout,
			int fetchSize,
			FlushMode flushMode,
			CacheMode? cacheMode,
			bool readOnly,
			string comment,
			IDictionary<string, string> parameterTypes,
			bool callable)
			: base(
				query.Trim(), /* trim done to workaround stupid oracle bug that cant handle whitespaces before a { in a sp */
				cacheable,
				cacheRegion,
				timeout,
				fetchSize,
				flushMode,
				cacheMode,
				readOnly,
				comment,
				parameterTypes
				)
		{
			this.queryReturns = queryReturns;
			this.querySpaces = querySpaces;
			this.callable = callable;
		}
		public SQLQueryReturnProcessor(
			INativeSQLQueryReturn[] queryReturns,
			ISessionFactoryImplementor factory)
		{
			this.queryReturns = queryReturns;
			this.factory = factory;
		}
		public SQLCustomQuery(INativeSQLQueryReturn[] queryReturns, string sqlQuery, ICollection<string> additionalQuerySpaces,
		                      ISessionFactoryImplementor factory)
		{
			log.Debug("starting processing of sql query [" + sqlQuery + "]");
			var processor = new SQLQueryContext(queryReturns, factory);

			var parser = new SQLQueryParser(factory, sqlQuery, processor);
			this.sql = parser.Process();
			this.customQueryReturns = GenerateCustomReturns(queryReturns, parser.QueryHasAliases, processor).ToList();
			this.parametersSpecifications = parser.CollectedParametersSpecifications.ToList();

			if (additionalQuerySpaces != null)
			{
				this.querySpaces.AddAll(additionalQuerySpaces);
			}
		}
Example #9
0
		public SQLCustomQuery(INativeSQLQueryReturn[] queryReturns, string sqlQuery, ICollection<string> additionalQuerySpaces,
		                      ISessionFactoryImplementor factory)
		{
			log.Debug("starting processing of sql query [" + sqlQuery + "]");
			SQLQueryReturnProcessor processor = new SQLQueryReturnProcessor(queryReturns, factory);
			SQLQueryReturnProcessor.ResultAliasContext aliasContext = processor.Process();

			SQLQueryParser parser = new SQLQueryParser(sqlQuery, new ParserContext(aliasContext));
			sql = parser.Process();
			ArrayHelper.AddAll(namedParameterBindPoints, parser.NamedParameters);
			ArrayHelper.AddAll(customQueryReturns, processor.GenerateCustomReturns(parser.QueryHasAliases));

			if (additionalQuerySpaces != null)
			{
				querySpaces.AddAll(additionalQuerySpaces);
			}
		}
 private void ProcessReturn(INativeSQLQueryReturn rtn)
 {
     if (rtn is NativeSQLQueryScalarReturn)
     {
         ProcessScalarReturn((NativeSQLQueryScalarReturn)rtn);
     }
     else if (rtn is NativeSQLQueryRootReturn)
     {
         ProcessRootReturn((NativeSQLQueryRootReturn)rtn);
     }
     else if (rtn is NativeSQLQueryCollectionReturn)
     {
         ProcessCollectionReturn((NativeSQLQueryCollectionReturn)rtn);
     }
     else
     {
         ProcessJoinReturn((NativeSQLQueryJoinReturn)rtn);
     }
 }
        private ResultSetMappingDefinition Create(string name, object[] items)
        {
            ResultSetMappingDefinition definition = new ResultSetMappingDefinition(name);

            int count = 0;

            foreach (object item in items ?? new object[0])
            {
                count += 1;
                INativeSQLQueryReturn queryReturn = CreateQueryReturn(item, count);

                if (queryReturn != null)
                {
                    definition.AddQueryReturn(queryReturn);
                }
            }

            return(definition);
        }
		private void ProcessReturn(INativeSQLQueryReturn rtn)
		{
			if (rtn is NativeSQLQueryScalarReturn)
			{
				ProcessScalarReturn((NativeSQLQueryScalarReturn) rtn);
			}
			else if (rtn is NativeSQLQueryRootReturn)
			{
				ProcessRootReturn((NativeSQLQueryRootReturn) rtn);
			}
			else if (rtn is NativeSQLQueryCollectionReturn)
			{
				ProcessCollectionReturn((NativeSQLQueryCollectionReturn) rtn);
			}
			else
			{
				ProcessJoinReturn((NativeSQLQueryJoinReturn) rtn);
			}
		}
Example #13
0
 private INativeSQLQueryReturn[] GetQueryReturns()
 {
     INativeSQLQueryReturn[] result = new INativeSQLQueryReturn[queryReturns.Count];
     queryReturns.CopyTo(result, 0);
     return(result);
 }
 public INativeSQLQueryReturn[] GetQueryReturns()
 {
     INativeSQLQueryReturn[] result = new INativeSQLQueryReturn[queryReturns.Count];
     queryReturns.CopyTo(result, 0);
     return result;
 }
 public void AddQueryReturn(INativeSQLQueryReturn queryReturn)
 {
     queryReturns.Add(queryReturn);
 }