cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Gentry <>
Subject Re: preDelete question
Date Thu, 14 Jul 2011 11:58:23 GMT
Hi John,

I'm not sure what third-party library/application you are using, but I
wonder if maybe you should be using a separate ObjectContext for your
inserted/deleted objects so you don't have to jump through such hoops?


On Wed, Jul 13, 2011 at 12:14 PM, Kuhns, John <> wrote:
> I've come across a situation where I need to short-circuit all database writes and deletes
for a third-party application. I am using Cayenne 3.0. On the prePersist and preUpdate callbacks,
the data object state is set to modified or new, so I can flip it to committed and call the
library methods for persisting the data. For preDelete, the state is committed and doesn't
flip to deleted until after the callback. I can and have worked around this, but was wondering
why the discrepancy exists.
> The only thing I can think of is that the data object content is emptied upon deletion
so the values wouldn't be available in the preDelete callback. If there is some method of
cancelling the delete within a prePersist callback I'd like to know about it. If not, I think
this is a necessary addition to the framework. Maybe a this.getObjectContext().pendingDeletedObjects()
that can be manipulated to remove an object from the list and short-circuit the delete?
> Thanks,
> John

View raw message