Пример #1
0
        private void AddResultSetMappingDefinitions(HbmMapping mappingSchema)
        {
            var binder = new ResultSetMappingBinder(Mappings);

            foreach (HbmResultSet resultSetSchema in mappingSchema.ResultSets)
            {
                // Do not inline this variable or the anonymous method will not work correctly.
                HbmResultSet tempResultSetSchema = resultSetSchema;

                mappings.AddSecondPass(delegate
                {
                    ResultSetMappingDefinition definition = binder.Create(tempResultSetSchema);
                    mappings.AddResultSetMapping(definition);
                });
            }
        }
        public void AddSqlQuery(HbmSqlQuery querySchema)
        {
            mappings.AddSecondPass(delegate
            {
                string queryName    = querySchema.name;
                string queryText    = querySchema.GetText();
                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      = null;
                bool callable       = querySchema.callable;
                string resultSetRef = querySchema.resultsetref;

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

                IDictionary <string, string> parameterTypes = new LinkedHashMap <string, string>();
                IList <string> synchronizedTables           = GetSynchronizedTables(querySchema);

                NamedSQLQueryDefinition namedQuery;

                if (string.IsNullOrEmpty(resultSetRef))
                {
                    ResultSetMappingDefinition definition =
                        new ResultSetMappingBinder(Mappings).Create(querySchema);

                    namedQuery = new NamedSQLQueryDefinition(queryText,
                                                             definition.GetQueryReturns(), synchronizedTables, cacheable, region, timeout,
                                                             fetchSize, flushMode, cacheMode, readOnly, comment, parameterTypes, callable);
                }
                else
                {
                    // TODO: check there is no actual definition elemnents when a ref is defined
                    namedQuery = new NamedSQLQueryDefinition(queryText,
                                                             resultSetRef, synchronizedTables, cacheable, region, timeout, fetchSize,
                                                             flushMode, cacheMode, readOnly, comment, parameterTypes, callable);
                }

                log.Debug("Named SQL query: {0} -> {1}", queryName, namedQuery.QueryString);
                mappings.AddSQLQuery(queryName, namedQuery);
            });
        }
		public void AddSqlQuery(HbmSqlQuery querySchema)
		{
			mappings.AddSecondPass(delegate
				{
					string queryName = querySchema.name;
					string queryText = querySchema.GetText();
					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 = null;
					bool callable = querySchema.callable;
					string resultSetRef = querySchema.resultsetref;

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

					IDictionary<string,string> parameterTypes = new LinkedHashMap<string,string>();
					IList<string> synchronizedTables = GetSynchronizedTables(querySchema);

					NamedSQLQueryDefinition namedQuery;

					if (string.IsNullOrEmpty(resultSetRef))
					{
						ResultSetMappingDefinition definition =
							new ResultSetMappingBinder(Mappings).Create(querySchema);

						namedQuery = new NamedSQLQueryDefinition(queryText,
							definition.GetQueryReturns(), synchronizedTables, cacheable, region, timeout,
							fetchSize, flushMode, cacheMode, readOnly, comment, parameterTypes, callable);
					}
					else
						// TODO: check there is no actual definition elemnents when a ref is defined
						namedQuery = new NamedSQLQueryDefinition(queryText,
							resultSetRef, synchronizedTables, cacheable, region, timeout, fetchSize,
							flushMode, cacheMode, readOnly, comment, parameterTypes, callable);

					log.DebugFormat("Named SQL query: {0} -> {1}", queryName, namedQuery.QueryString);
					mappings.AddSQLQuery(queryName, namedQuery);
				});
		}
Пример #4
0
        private void AddResultSetMappingDefinitions(HbmMapping mappingSchema)
        {
            ResultSetMappingBinder binder = new ResultSetMappingBinder(this);

            foreach (HbmResultSet resultSetSchema in mappingSchema.resultset ?? new HbmResultSet[0])
            {
                // Do not inline this variable or the anonymous method will not work correctly.
                HbmResultSet tempResultSetSchema = resultSetSchema;

                mappings.AddSecondPass(delegate
                    {
                        ResultSetMappingDefinition definition = binder.Create(tempResultSetSchema);
                        mappings.AddResultSetMapping(definition);
                    });
            }
        }