You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Marek Šabo <ms...@buk.cvut.cz> on 2012/12/28 13:50:23 UTC

Queries during lost connections

Hi all,

is there any hook for handling lost connections in Cayenne?

My use-case is a system that uses Cayenne with remote database. But when 
the network is down it still needs to fall-back to set of last known values.

I would like to know if Cayenne can let me know somehow that it lost 
connection to DB.

Another thing is - when the DB connection is lost, does Cayenne still 
serve whatever it has in cache? I use only selects and only one insert.

Thanks for ideas,

Marek

Re: Queries during lost connections

Posted by Mike Kienenberger <mk...@gmail.com>.
On Fri, Dec 28, 2012 at 7:50 AM, Marek Šabo <ms...@buk.cvut.cz> wrote:
> is there any hook for handling lost connections in Cayenne?

I can't find our most recent documentation on this, but it used to
happen automatically with supported databases.

https://cwiki.apache.org/removed/CAY/reconnect.html

http://objectstyle.org/cayenne/lists/cayenne-user/2005/04/0053.html

I have a Cayenne 1.1 system that I maintain which uses Oracle, and
while it may have to fail on two or three queries because of the cycle
of errors returned from an Oracle database when the connection is
lost, it does recover after about three queries.


> My use-case is a system that uses Cayenne with remote database. But when the
> network is down it still needs to fall-back to set of last known values.
>
> I would like to know if Cayenne can let me know somehow that it lost
> connection to DB.
>
> Another thing is - when the DB connection is lost, does Cayenne still serve
> whatever it has in cache? I use only selects and only one insert.

You will have to write your own code to handle what to do during the
failed queries.   A disconnect-related error should come back as a
CayenneRuntimeException.    When you handle it, you will need to
determine if it's a a lost connection error (it probably could be
assumed to be once you're in production) and then return a different
set of queries.   I haven't tried to do this, so I can't tell you the
best way to pull the objects out of a cache.