cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <>
Subject Re: need some help
Date Thu, 20 Jun 2019 09:12:01 GMT
Also #3:

Since DbAdapter serves as SQLAction factory for the entire stack, you may install a Statement
timeout-aware custom DbAdapter. There are also a few levels of indirection to do that. I think
the simplest is to create a custom Module [1] like this:

public class MyModule implements Module {

    public void configure(Binder binder) {

and then implement MyDbAdapterFactory to return your own adapter, subclassing whatever DbAdapter
is appropriate for your DB (e.g. MySQLAdapter), overriding it "getAction" method to return
that action that can manipulate the statement timeout.

(Like I said, we need to do better in the future, so that you won't have to jump through so
many hoops to access the JDBC layer)



> On Jun 20, 2019, at 10:49 AM, Andrus Adamchik <> wrote:
>> On Jun 20, 2019, at 10:33 AM, zhengyan <> wrote:
>> Hi, I'm using the Cayenne3.1.2 version .
>> I want to set the QueryTimeout parameter , like the parameter in
>> JDBC setQueryTimeout(5);
>> Where I can set this parameter in Cayenne3.1.2?
>> Thanks !
> Hi,
> Unfortunately there's no direct way to do it, and you will have to implement some roundabout
> 1. Your connection pool may support a default query timeout. E.g. DBCP has "defaultQueryTimeout"
config parameter.
> 2. You may need to subclass your SelectQuery, to implement a custom "createSQLAction"
method, them subclass your DB-specific SelectAction to control the Statement.
> The second solution would require poking inside a few Cayenne internals, but is not as
scary as it may seem :)
> Also I made a note to explore exposing JDBC Statements in some way for user customization,
so hopefully the future versions of Cayenne will allow for a more direct approach.
> Andrus
> [1]

View raw message