If the column name is the same in all the tables it would be pretty easy to
loop over all your entities and execute the same delete statement (via raw
SQLExec). Put all the the entities with that column in a Set and loop over
them, removing one when it succeeds until the set is empty.

On Wed, May 29, 2019 at 7:35 AM Hugi Thordarson <h...@karlmenn.is> wrote:

> Hi all.
>
> I have a pretty large model where every to-many relationship's delete rule
> is "Deny" (I like being explicit about the data I delete, especially since
> the DB in question still doesn't have well specified FKs).
>
> Almost every table in this DB is somehow related to a "Customer" table
> (sometimes through a chain of tables) that "owns" data.
> I'm now implementing an operation to nuke a Customer (as in "delete
> everything related to that customer")—but the data  "owned" by the customer
> is hugely interrelated, even often creating circular relations.
>
> Do I have any nice options, given a set of DataObjects, to just tell
> Cayenne to nuke that darn data without any consideration for normal delete
> rules? As in "usually I wouldn't allow this and Ashwood is very angry at
> you—but since you really, really want it…".
>
> Note that the whole operation results in a consistent database (even if
> there are temporary in-memory inconsistencies due to the circular
> relationships) since the interrelated data is all deleted within the
> operation.
>
> Cheers,
> - Hugi

Reply via email to