Пример #1
0
        private int BindQueryParameters(IDbCommand command, int queryIndex, int colIndex)
        {
            QueryParameters parameter = parameters[queryIndex];

            colIndex += parameter.BindParameters(command, colIndex, session);
            return(colIndex);
        }
Пример #2
0
 private int BindQueryParameters(IDbCommand command, int colIndex)
 {
     for (int i = 0; i < loaders.Count; i++)
     {
         QueryParameters parameter = parameters[i];
         colIndex += parameter.BindParameters(command, loaders[i].GetNamedParameterLocs, colIndex, session);
     }
     return(colIndex);
 }
Пример #3
0
        // DONE : H3.2 Executable query (now can be supported for named SQL query/ storedProcedure)
        public int PerformExecuteUpdate(QueryParameters queryParameters, ISessionImplementor session)
        {
            CoordinateSharedCacheCleanup(session);

            if (queryParameters.Callable)
            {
                throw new ArgumentException("callable not yet supported for native queries");
            }

            RowSelection selection = queryParameters.RowSelection;

            int result;

            try
            {
                queryParameters.ProcessFilters(customQuery.SQL, session);
                SqlString sql      = queryParameters.FilteredSQL;
                SqlType[] sqlTypes = queryParameters.PrepareParameterTypes(sql, session.Factory, GetNamedParameterLocs, 0, false, false);

                IDbCommand ps = session.Batcher.PrepareCommand(CommandType.Text, sql, sqlTypes);

                try
                {
                    if (selection != null && selection.Timeout != RowSelection.NoValue)
                    {
                        // NH Difference : set Timeout for native query
                        ps.CommandTimeout = selection.Timeout;
                    }
                    // NH Different behavior:
                    // The inital value is 0 (initialized to 1 in JAVA)
                    // The responsibility of parameter binding was entirely moved to QueryParameters
                    // to deal with positionslParameter+NamedParameter+ParameterOfFilters

                    queryParameters.BindParameters(ps, 0, session);
                    result = session.Batcher.ExecuteNonQuery(ps);
                }
                finally
                {
                    if (ps != null)
                    {
                        session.Batcher.CloseCommand(ps, null);
                    }
                }
            }
            catch (HibernateException)
            {
                throw;
            }
            catch (Exception sqle)
            {
                throw ADOExceptionHelper.Convert(session.Factory.SQLExceptionConverter, sqle,
                                                 "could not execute native bulk manipulation query:" + sourceQuery);
            }

            return(result);
        }
Пример #4
0
 private int BindQueryParameters(IDbCommand command, int colIndex)
 {
     for (int i = 0; i < queries.Count; i++)
     {
         IQueryTranslator translator = Translators[i];
         QueryParameters  parameter  = Parameters[i];
         colIndex += parameter.BindParameters(command, translator.Loader.GetNamedParameterLocs, colIndex, session);
     }
     return(colIndex);
 }
Пример #5
0
		// DONE : H3.2 Executable query (now can be supported for named SQL query/ storedProcedure)
		public int PerformExecuteUpdate(QueryParameters queryParameters, ISessionImplementor session)
		{
			CoordinateSharedCacheCleanup(session);

			if (queryParameters.Callable)
			{
				throw new ArgumentException("callable not yet supported for native queries");
			}

			RowSelection selection = queryParameters.RowSelection;

			int result;
			try
			{
				queryParameters.ProcessFilters(customQuery.SQL, session);
				SqlString sql = queryParameters.FilteredSQL;
				SqlType[] sqlTypes = queryParameters.PrepareParameterTypes(sql, session.Factory, GetNamedParameterLocs, 0, false, false);
				
				IDbCommand ps = session.Batcher.PrepareCommand(CommandType.Text, sql, sqlTypes);

				try
				{
					if (selection != null && selection.Timeout != RowSelection.NoValue)
					{
						// NH Difference : set Timeout for native query
						ps.CommandTimeout = selection.Timeout;
					}
					// NH Different behavior:
					// The inital value is 0 (initialized to 1 in JAVA)
					// The responsibility of parameter binding was entirely moved to QueryParameters
					// to deal with positionslParameter+NamedParameter+ParameterOfFilters
					
					queryParameters.BindParameters(ps, 0, session);
					result = session.Batcher.ExecuteNonQuery(ps);
				}
				finally
				{
					if (ps != null)
					{
						session.Batcher.CloseCommand(ps, null);
					}
				}
			}
			catch (HibernateException)
			{
				throw;
			}
			catch (Exception sqle)
			{
				throw ADOExceptionHelper.Convert(session.Factory.SQLExceptionConverter, sqle,
				                                 "could not execute native bulk manipulation query:" + sourceQuery);
			}

			return result;
		}
Пример #6
0
 protected virtual int BindQueryParameters(IDbCommand command, QueryParameters parameter, int colIndex)
 {
     colIndex += parameter.BindParameters(command, colIndex, session);
     return(colIndex);
 }