public void AddQuery(HbmQuery querySchema)
		{
			string queryName = querySchema.name;
			string queryText = querySchema.GetText();

			log.DebugFormat("Named query: {0} -> {1}", queryName, queryText);

			bool cacheable = querySchema.cacheable;
			string region = querySchema.cacheregion;
			int timeout = string.IsNullOrEmpty(querySchema.timeout) ? RowSelection.NoValue : int.Parse(querySchema.timeout);
			int fetchSize = querySchema.fetchsizeSpecified ? querySchema.fetchsize : -1;
			bool readOnly = querySchema.readonlySpecified ? querySchema.@readonly : false;
			string comment = querySchema.comment;

			FlushMode flushMode = FlushModeConverter.GetFlushMode(querySchema);
			CacheMode? cacheMode = (querySchema.cachemodeSpecified)
										? querySchema.cachemode.ToCacheMode()
										: null;

			IDictionary<string,string> parameterTypes = new LinkedHashMap<string,string>();

			var namedQuery = new NamedQueryDefinition(queryText, cacheable, region, timeout,
				fetchSize, flushMode, cacheMode, readOnly, comment, parameterTypes);

			mappings.AddQuery(queryName, namedQuery);
		}
		public void AddQuery(string name, NamedQueryDefinition query)
		{
			CheckQueryExists(name);
			queries[name] = query;
		}
Esempio n. 3
0
		private static void BindNamedQuery(XmlNode queryElem, string path, Mappings mappings)
		{
			string queryName = queryElem.Attributes["name"].Value;
			if (path != null)
			{
				queryName = path + '.' + queryName;
			}
			string query = queryElem.InnerText;
			log.Debug("Named query: " + queryName + " -> " + query);

			bool cacheable = "true".Equals(XmlHelper.GetAttributeValue(queryElem, "cacheable"));
			string region = XmlHelper.GetAttributeValue(queryElem, "cache-region");
			XmlAttribute tAtt = queryElem.Attributes["timeout"];
			int timeout = tAtt == null ? -1 : int.Parse(tAtt.Value);
			XmlAttribute fsAtt = queryElem.Attributes["fetch-size"];
			int fetchSize = fsAtt == null ? -1 : int.Parse(fsAtt.Value);
			XmlAttribute roAttr = queryElem.Attributes["read-only"];
			bool readOnly = roAttr != null && "true".Equals(roAttr.Value);
			XmlAttribute cacheModeAtt = queryElem.Attributes["cache-mode"];
			string cacheMode = cacheModeAtt == null ? null : cacheModeAtt.Value;
			XmlAttribute cmAtt = queryElem.Attributes["comment"];
			string comment = cmAtt == null ? null : cmAtt.Value;

			NamedQueryDefinition namedQuery = new NamedQueryDefinition(
				query,
				cacheable,
				region,
				timeout,
				fetchSize,
				GetFlushMode(XmlHelper.GetAttributeValue(queryElem, "flush-mode")),
				//GetCacheMode(cacheMode),
				readOnly,
				comment,
				GetParameterTypes(queryElem)
				);

			mappings.AddQuery(queryName, namedQuery);
		}