Re: Query timeout in QueryMetadata

John Huss <[email protected]>
Newsgroups gmane.comp.java.cayenne.user
Message-ID <CAOUwSGuM3a9KGVCGX=tdJXYng_G38TU6Lhix56Fm9O4YzNpwtQ@mail.gmail.com>
The answer might vary depending on your specific use case. One way to do it
would be to:

1) start an explicit transaction,
2) run a query to set the timeout
            SQLExec.*query*("set statement_timeout = 60000").execute(context
);
3) do your work
4) run a query to reset or unset the timeout
5) commit

TransactionFactory txFactory = CayenneRuntime.*getThreadInjector*
().getInstance(TransactionFactory.*class*);

Transaction tx = txFactory.createTransaction();

tx.begin();

*try* {

... // do stuff


tx.commit();

} *catch* (Exception e) {

tx.rollback();

*throw* e;

}


On Tue, Nov 10, 2020 at 7:50 AM Mark Stobbe <[email protected]> wrote:

> Hi all,
>
> Can we have an option to set query timeout on the metadata of the query,
> similar to the statementFetchSize?
>
> The workaround seems to involve a lot of subclasses via the adapter; or via
> the connection but then I need to have the same timeout for all statements
> or parse SQL to identify query..
>
> Best regards,
> Mark
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.