cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hugi Thordarson <h...@karlmenn.is>
Subject Re: Deleting a bunch of interrelated objects
Date Wed, 29 May 2019 22:16:54 GMT
Yeah, I'll probably end up doing something like that. Although the column name isn't always
the same (data "owned" by a Customer can go Customer ->> Invoice ->> InvoiceLine
->> InvoiceLineSums ->> etc) plain SQL is probably the way to go here. I'll just
write out them damn joins like our ancestors did.

Thanks,
- hugi



> On 29 May 2019, at 15:26, John Huss <johnthuss@gmail.com> wrote:
> 
> 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 <hugi@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


Mime
View raw message