[quote="KenR"]Good point...it just so happens that for our requirement it isn't necessarily a stalled transaction, just one that is too slow. Our requirements say that once we've exceeded the limits set on a particular query (i.e. due to load or number of records, or even due to database explosion), we're supposed to fail over to a backup datasource containing slightly lagging (30 mins on average) data. In other words, we have a contract that states the maximum amount of time each particular call will take.
Since you've so kindly provided Session.cancelQuery, we'll just have to write the monitor thread ourselves and kill anything that runs too long.[/quote]
The problem though is that the query was fired by a http request and if the user wants to cancel it by press of a button, how would I get an handle to that query which is already running in the DB?
I have created a forum question for the same. please refer
http://forum.hibernate.org/viewtopic.ph ... ancelquery
my code segment is
Session session = getSession();
org.hibernate.Transaction trans = session.getTransaction();
trans.begin();
session.cancelQuery();
trans.rollback();
Even after this, I am able to see the query that is running in the DB and gets timed out after some time.
Is there any possibility that we can get handle to the query which is active in the DB?
Would be happy to get your assistance in this ASAP.