Re: need some help

Andrus Adamchik <[email protected]>
Newsgroups gmane.comp.java.cayenne.user
Message-ID <[email protected]>

> On Jun 20, 2019, at 10:33 AM, zhengyan <[email protected]> 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 approach:

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] https://commons.apache.org/proper/commons-dbcp/configuration.html
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.