Re: Reconnecting automatically after DB downtime

2016-02-29 Thread Aristedes Maniatis
On 29/02/2016 9:53pm, Hugi Thordarson wrote: > Hi all. > We had some DB problems last night (MariaDB with the ConnectorJ driver). As > soon as I had started the DB back up, our EOF applications were up and > running, but the Cayenne apps were still down and required a restart to start > running

Reconnecting automatically after DB downtime

2016-02-29 Thread Hugi Thordarson
Hi all. We had some DB problems last night (MariaDB with the ConnectorJ driver). As soon as I had started the DB back up, our EOF applications were up and running, but the Cayenne apps were still down and required a restart to start running again. Is there any way to tell Cayenne to reconnect

Re: Reconnecting automatically after DB downtime

2016-02-29 Thread Hugi Thordarson
Hi Michael, I’m not quite sure, I’m just giving Cayenne my connection information. Should I be using a different mechanism? Cheers, - hugi > On 29. feb. 2016, at 13:10, Michael Gentry wrote: > > Hi Hugi, > > Just out of curiosity, which connection pooling mechanism

Re: Reconnecting automatically after DB downtime

2016-02-29 Thread Hugi Thordarson
Thanks Andrus. I do have “autoReconnect=true” in the string but added the connectionTimeout, perhaps that helps. What does validationQuery do? Cheers, - hugi // Hugi Thordarson // http://www.loftfar.is/ // s. 895-6688 > On 29. feb. 2016, at 10:57, Andrus Adamchik

Re: Reconnecting automatically after DB downtime

2016-02-29 Thread Hugi Thordarson
Ah, awesome. Added to my config :). Cheers, - hugi > On 29. feb. 2016, at 11:25, Andrus Adamchik wrote: > > >> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson wrote: >> >> What does validationQuery do? > > Periodically executes for each pooled

Re: Reconnecting automatically after DB downtime

2016-02-29 Thread Andrus Adamchik
> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson wrote: > > What does validationQuery do? Periodically executes for each pooled connection, and kills connections that throw during validation. So it ensures that all pooled connections are in a good state. Andrus

Counting the number of destination objects for a to-many relationship (or checking if empty)

2016-02-29 Thread Hugi Thordarson
Hi all, Is there any simple way or me to count the number of destination objects of a to-many relationship? (without fetching) If not, is there some way to generate an expression from a relationship, so I can use that expression in my own counting functions? Cheers, - hugi

Re: Reconnecting automatically after DB downtime

2016-02-29 Thread Andrus Adamchik
Probably a DataSource configuration. I am using DB urls like this: jdbc:mysql://127.0.0.1/db?connectTimeout=0=true=true=UTF-8 and also add "validationQuery" parameter to my pool config. Both ensure reconnects are transparent. Andrus > On Feb 29, 2016, at 1:53 PM, Hugi Thordarson

Re: Reconnecting automatically after DB downtime

2016-02-29 Thread Hugi Thordarson
I’m using Cayenne’s internal mechanism for everything related to the DB and currently using 4.0.M4-SNAPSHOT. The stack trace we were getting (after restarting the DB, and the EOF programs had started working) was: Caused by:

Re: Reconnecting automatically after DB downtime

2016-02-29 Thread Michael Gentry
Hi Hugi, I don't know the nature of your application. I've used Cayenne's native connection pooling (stand-alone applications) and JNDI (typically based on Apache Commons DBCP) in the past. If my memory is correct, Cayenne's native connection pooling does attempt to do a re-connect on failure.

Re: Counting the number of destination objects for a to-many relationship (or checking if empty)

2016-02-29 Thread Michael Gentry
PS. I think the code works correctly, but let me know if it doesn't. On Mon, Feb 29, 2016 at 1:09 PM, Michael Gentry wrote: > Hi Hugi, > > I'm not sure if this will work for 4.0 (since earlier you said you are > using it), but this is what I'd use for 3.1: > > >

Re: Counting the number of destination objects for a to-many relationship (or checking if empty)

2016-02-29 Thread Michael Gentry
Hi Hugi, I'm not sure if this will work for 4.0 (since earlier you said you are using it), but this is what I'd use for 3.1: https://github.com/mrg/cbe/blob/master/FetchingObjects/Aggregates/src/main/java/cbe/fetching/utilities/AggregateUtils.java If you have A->>B, you'd construct a