Skip to content

NH-3034 - CancelQuery support for the queries run by .ExecuteUpdate #973

Open
@nhibernate-bot

Description

@nhibernate-bot

Onur Gumus created an issue — 25th January 2012, 10:43:52:

Currently there is no way to cancel such a query like :
session.CreateSQLQuery("delete from sometable").ExecuteUpdate();

Calling CancelQuery from another thread will do nothing due to : ExecuteUpdate will eventually call :

public IDbCommand PrepareCommand(CommandType type, SqlString sql, SqlType[] parameterTypes)
{
	this.OnPreparedCommand();
	return this.Generate(type, sql, parameterTypes);
}

method of the AbstractBatcher.

However a normal query will run through :

public IDbCommand PrepareQueryCommand(CommandType type, SqlString sql, SqlType[] parameterTypes)
{
	IDbCommand result = this.Generate(type, sql, parameterTypes);
	this.lastQuery = result;
	return result;
}

As you see this.lastQuery has been set. Thus it makes it cancellable via :

public void CancelLastQuery()
{
	try
	{
		if (this.lastQuery != null)
		{
			this.lastQuery.Cancel();
		}
....

}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions