If a user presses the "search" button and then they decide to do "something else", we have to cancel an already running query.
We use Hibernate (and Oracle) as persistence solution. Hibernates Session interface provides a cancelQuery()
method. After some testing, it seems that cancelQuery()
has no effect.
Does anybody have some experience with this Session#cancelQuery()
method?
Thank you!
Hibernate is a Java framework that makes it easier to create database-interactive Java applications. In HQL, instead of a table name, it uses a class name. As a result, it is a query language that is database-independent. Hibernate converts HQL queries into SQL queries, which are then used to perform database actions.
In hibernate, you can execute your native SQL queries using the Session. createNativeQuery() method. Execute simple and complex native SQL query in hibernate application. Map native SQL query result to an @Entity object.
It has an effect but with the Oracle JDBC driver, it just takes some time to happen. Just wait a minute or two.
If you can't wait, then move the cancel in a background thread (along with the session) and request a new Hibernate session in your main thread. You can't use the old session until cancelQuery()
returns.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With