cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Juan Manuel Diaz Lara <>
Subject Re: How to execute a stored procedure as part of a commitChanges?
Date Mon, 11 Apr 2016 15:31:30 GMT

I am using 4.0.M3.
I used the following solution, but the problem is that after commitChanges() the dataobjetcs
are set to PersistenceState.COMMITED, if the stored procedure fails Cayenne does a DB rollback
(that's ok), but dataobjects stay COMMITED, so I can not retry the this transaction after
errors are solved.
Is there any way to revert the persistenceState to their values before commitChanges if I
detect the stored procedure failed ?

            cayenneRuntime.performInTransaction(new TransactionalOperation<Integer>()

                        public Integer perform() {
                            SQLTemplate s = new SQLTemplate("SELECT pkg_inventario_fisico.apply(
#bind($idAlmacen, 'VARCHAR')) AS id", true);
                            List<DataRow> rows = CayenneDao.instance.context.performQuery(s);
                            DataRow row = rows.get(0);
                            return null;
 Atte. Juan Manuel Díaz Lara 

    On Monday, April 11, 2016 10:06 AM, Mike Kienenberger <> wrote:

 See the bottom part of this page starting at "In the second scenario":

On Mon, Apr 11, 2016 at 10:54 AM, Juan Manuel Diaz Lara
<> wrote:
>  I have a dataobjet graph with some changes, and a db stored procedure that should run
after this changes are in the db, but must run in the same transaction because it make some
more changes to other data, this changes can fail so I want the commitChanges fail if the
stored procedure fails.
>  Atte. Juan Manuel Díaz Lara

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message