Hi Juan,

couldn't you do this more easily and reliably with a db trigger?

Maik


> Am 06.03.2018 um 16:11 schrieb Juan Manuel Diaz Lara 
> <jmdia...@yahoo.com.INVALID>:
> 
> Is there any way to call a stored procedure as part of commitChanges ?
> I would like to call a stored procedure after flushing my persistent objects 
> but before the real db commit, for instance, to make some process on the db 
> as part of committing my objects, but transactionally. 
> 
> performInTransaction(..) {     commitChanges(); //Only flush to db, no 
> commit, no in memory accounting of commit (no modifications to 
> persitenctState)
>     procedureCall.call(..); //Call a SP, save db transaction, can 
> post-process data, and if it throws exception we can rollback db and 
> persistentState stays the same before commitChanges  
> }
> I am now om 4.0.M5.
> 
> In a previous version (I do not remember which), I made some hack to replace 
> DataDomain and other classes to allow to differ the in memory accounting of 
> persistent objects until the db commit is done and allow call a SP after 
> commitChanges() in the same db commit, I made a module to install my hacks, 
> but it is not working now on M5, maybe new rules to replace cayenne services:
> 
> public class ServerModuleWithPostCommitActions implements 
> org.apache.cayenne.di.Module {
> 
>     @Override
>     public void configure(Binder binder) {
>         
>         
> binder.bindList(Constants.SERVER_DOMAIN_FILTERS_LIST).add(PCATransactionFilter.class);
>         
>         
> binder.bind(TransactionFactory.class).to(TransactionWithPostCommitActionsFactory.class);
>         
>         binder.bind(DataDomain.class).toProvider(PCADataDomainProvider.class);
>         
>         
> binder.bind(ObjectContextFactory.class).to(PCADataContextFactory.class);
>         
>     }
> }
> 
> This worked, but it was not a clear solution. specifically 
> PCADataDomainProviderPCA is never called.
> Thanks.
> 
> Atte. Juan Manuel Díaz Lara

Reply via email to